Please find below a sample program which allows to generate the current date and time in ABAP.
The date time can also be returned based on the timezone set.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
REPORT ZTIMEDATE. *Data Declarations. *Variables: DATA: lv_currenttime TYPE brf_ref_time_stamp. *Constants: CONSTANTS: lc_tzone TYPE sy-zonlo VALUE space. *Creation Date Column. *Get the current system time. GET TIME. *Convert the time to the correct format *before adding it to the traceability table. *Please note that the format of the time will *be 'YYYYMMDDhhmmss'. *For example: 20170101052501 which equals to 2017-01-01 05:25:01. CONVERT DATE sy-datum " Date TIME sy-uzeit " Time INTO TIME STAMP lv_currenttime " Creation Date Time TIME ZONE lc_tzone. " Timezone *Write Time. WRITE lv_currenttime. |
Please note that the data element ‘BRF_REF_TIME_STAMP’ contains the domain ‘BRF_TIMESTAMP’ which has a conversion routine which also returns the date/time in the format ‘DD-MM-YYYY HH:MM:SS’.