当在创建日志表,想生成一个永远不会重复的序列号做唯一键值,来保证每次日志记录都不会被覆盖。
有两种方式,一种带日期的方式,一种是纯GUI ID,参考如下:
1.
data: lv_timestamp type timestampl,
lv_time_c(30) type c,
lv_date type sy-datum,
lv_time type sy-uzeit.
get time stamp field lv_timestamp.
write lv_timestamp to lv_time_c time zone sy-zonlo.
convert time stamp lv_timestamp time zone sy-zonlo into date lv_date time lv_time.
ex_seqid = |{ lv_date }{ lv_time }.{ lv_time_c+20(7) }|.
2.
data: lv_guid22 type sysuuid_c22,
lv_guid26 type sysuuid_c26,
lv_guid32 type sysuuid_c32,
lo_uuid type ref to cl_system_uuid.
try.
create object lo_uuid.
call method lo_uuid->if_system_uuid~create_uuid_c22
receiving
uuid = lv_guid22.
ex_guid22 = lv_guid22.
catch cx_uuid_error .
endtry.