abap时间戳的获取

通过convert函数可以将日期和时间值转换为时间戳(短格式的YYYYMMDDhhmmss):

DATA: dat TYPE sy-datum,
      tim TYPE sy-uzeit,
      timstmp TYPE timestamp
      .

dat = sy-datum.
tim = sy-uzeit.

PERFORM convert_datum_to_timestamps USING dat tim CHANGING timstmp.

WRITE: '现在时间:', timstmp.

*
*&---------------------------------------------------------------------*
*&      Form  convert_datum_to_timestamps
*&---------------------------------------------------------------------*
FORM convert_datum_to_timestamps USING p_date TYPE d
                                       p_time TYPE t
                                 CHANGING p_timestamp TYPE timestamp.
  DATA: l_timezone  LIKE ttzz-tzone.
  CONVERT DATE p_date
          TIME p_time
          INTO
          TIME STAMP p_timestamp  TIME ZONE l_timezone.
ENDFORM. 


你可能感兴趣的:(abap时间戳的获取)