ABAP Help Document(18):9.3时间类型数据运算

9.3Date and Time Processing

          Tcode: STZBD,查看Time Zone。

Table:

TTZZ,Time Zone数据表;

TTZR,UTC refrence差异时区数据表;

TTZD, TTZDF, and TTZDV,夏令时配置数据表;

类CL_ABAP_TSTMP,计算timestamps

系统预定义时间数据对象:

sy-datlo:用户日期

sy-datum:系统日期

sy-dayst:夏令时,'X',否则‘’

sy-fdayw:1-5,monday-friday

sy-timlo:用户时间

sy-tzone:UTC系统时区

sy-uzeit:系统时间

sy-zonlo:用户时区

示例:

"date,time
"时间戳转换
*CONVERT TIME STAMP time_stamp TIME ZONE tz
*        INTO [DATE dat]
*             [TIME tim] [DAYLIGHT SAVING TIME dst].
*CONVERT DATE dat
*        [TIME tim [DAYLIGHT SAVING TIME dst]]
*        INTO TIME STAMP time_stamp TIME ZONE tz.
"获取时间
*GET TIME [FIELD tim]. 
FORM f_character_process_date.
  "时间戳类型TIMESTAMP,length16,yyyymmddhhmmss
  "时间戳长类型TIMESTAMPL,length21,yyyymmddhhmmss.sssssss
  DATA:lv_timestamp TYPE timestamp.
  DATA:lv_date TYPE d.
  DATA:lv_time TYPE t.
  DATA:lv_day TYPE I.
  DATA:lv_hour TYPE I.
  DATA:lv_minute TYPE I.
  DATA lv_tz TYPE tzonref-tzone VALUE 'BRAZIL'.
  "获取timestamp
  GET TIME STAMP FIELD lv_timestamp.
  "转换date,time
  CONVERT TIME STAMP lv_timestamp TIME ZONE sy-zonlo
    INTO DATE lv_date TIME lv_time.
  WRITE:/ lv_date,lv_time.
  "转换为timestamp
  CONVERT DATE lv_date TIME lv_time DAYLIGHT SAVING TIME ''
    INTO TIME STAMP lv_timestamp TIME ZONE lv_tz.
  WRITE:/ lv_timestamp.
ENDFORM.
posted @ 2021-04-22 19:53  渔歌晚唱  阅读(208)  评论(0编辑  收藏  举报