abap - 我可以在 ABAP CDS 视图中创建 GUID 吗?
问题描述
我在 ABAP CDS 视图中将一个表连接到自身,并希望为每行创建一个唯一的 GUID。那可能吗?
就像是:
select from my_view as a
inner join my_view as b
on a.ContextKey = b.ContextKey and
a.DbKey != b.DbKey
{
key sysuuid as MAPPING_ID,
a.SomeField AS A,
b.SomeField AS B
}
解决方案
我不知道UUID
CDS 中有任何功能。您需要使用CDS Table Function
和AMDP
。
你的Table Function
看法。
define table function ZP_TF_TEST
with parameters @Environment.systemField: #CLIENT mandt : mandt
returns
{
mandt : mandt;
ID : uuid;
A : type_a;
B : type_b;
}
implemented by method zcl_tf_test=>get_data;
你的CDS
看法。
define view ZZ_TF_TEST as select from ZP_TF_TEST( mandt : $session.client )
{
key ID,
A,
B,
}
你的AMDP
课。
CLASS zcl_tf_test DEFINITION PUBLIC FINAL CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_amdp_marker_hdb .
CLASS-METHODS get_data
FOR TABLE FUNCTION ZP_TF_TEST.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
实现方法get_data
并使用SELECT sysuuid FROM dummy
METHOD get_data BY DATABASE FUNCTION FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING my_table.
RETURN SELECT
a.mandt,
( SELECT sysuuid FROM dummy ) as id,
a.SomeField AS A,
b.SomeField AS B
from my_table as a inner join my_table as b
on a.ContextKey = b.ContextKey and a.DbKey != b.DbKey
where a.mandt= :mandt;
ENDMETHOD.
推荐阅读
- regex - Vercel.json 重定向正则表达式以匹配除文件之外的任何内容
- mysql - Mysql如何使用触发器插入所有更新的旧行和新行
- c# - Jquery 数据表 - 表中没有可用数据
- robotframework - 如何将 CSV 文件与 Robotframework 连接起来
- python - 使用正则表达式、循环、枚举解析复杂的字符串列表以生成熊猫数据框
- postgresql - 无法完成 pgadmin4 设置。阿帕奇网络服务器
- server - 重置安装了让我们加密 ssl 证书的 apache Web 服务器虚拟主机的项目目录
- css - React-Admin - 添加材质 ui 主题将特定的 css 选择器覆盖为全局
- azure - 如何在 SPA (ADB2C) 中关闭浏览器和 24 小时后保持用户登录
- javascript - 使用 REST 端点获取 Youtube Data API v3 OAuth2 令牌时出现问题