我可以在ABAP CDS视图中创建GUID吗?
我正在ABAP CDS视图中将一个表连接到它自己,并且希望每行创建一个唯一的GUID。可能吗 比如:我可以在ABAP CDS视图中创建GUID吗?,abap,cds,Abap,Cds,我正在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 } 我不知道
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
}
我不知道CD中有任何
UUID
功能。您需要使用CDS表函数
和AMDP
您的表函数
视图
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;
define view ZZ_TF_TEST as select from ZP_TF_TEST( mandt : $session.client )
{
key ID,
A,
B,
}
您的cd
视图
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;
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
并使用从虚拟对象中选择sysuuid
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.
已经问过