递增且唯一的少于20位的数字,建议时间戳
FUNCTION ZFM_TIMESTAMP .
*"----------------------------------------------------------------------
*"*"本地接口:
*" EXPORTING
*" VALUE(TAMP) TYPE STRING
*"----------------------------------------------------------------------
DATA: lv_date TYPE sy-datum,
lv_time TYPE sy-uzeit,
lv_msec TYPE n LENGTH 3,
lv_saptimestamp TYPE tzntstmpl, "timestamp,
lv_javatimestamp TYPE string,
lv_amount TYPE string,
lv_decimals TYPE string.
*获取sap时间戳(格林威治时间)
GET TIME STAMP FIELD lv_saptimestamp .
*将时间戳转换为日期时间(此时的日期是格林威治日期时间)
CONVERT TIME STAMP lv_saptimestamp TIME ZONE 'UTC' "UTC+8
INTO DATE lv_date
TIME lv_time .
lv_amount = lv_saptimestamp.
SPLIT lv_amount AT '.' INTO lv_amount lv_decimals.
lv_msec = lv_decimals+0(3).
*时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数。
CALL METHOD cl_pco_utility=>convert_abap_timestamp_to_java
EXPORTING
iv_date = lv_date
iv_time = lv_time
iv_msec = lv_msec
IMPORTING
ev_timestamp = lv_javatimestamp. "JAVA时间戳
tamp = lv_javatimestamp.
ENDFUNCTION.
gs_head-batchnum = tamp. ": "递增且唯一的少于20位的数字,建议时间戳",