How to convert UTC timestamp to system date and time in ABAP

Do any of you have any suggestions on how to convert a given UTC timestamp to the date and time of the system time zone?

Converting from a UTC timestamp to a local time zone of users is easy, you can simply do:

CONVERT TIME STAMP lv_utc_timestamp TIME ZONE sy-zonlo
          INTO DATE lv_local_date TIME lv_local_time.

But how to do this for system time - system time is necessary in many situations, for example. when calling the function module JOB_CLOSE. The only solution I have found so far is this:

SELECT SINGLE * FROM TTZCU INTO ls_ttzcu.
CONVERT TIME STAMP lv_utc_timestamp TIME ZONE ls_ttzcu-tzonesys
          INTO DATE lv_system_date TIME lv_system_time.

Is this already the best solution or can I restore the system time zone in a different way? Is there always a valid time zone from an entry in the TTZCU table? Any ideas?

: @rmtiwari twitter, FLAGACTIVE TTZCU ,

SELECT SINGLE * FROM TTZCU INTO ls_ttzcu WHERE flagactive = abap_true.
CONVERT TIME STAMP lv_utc_timestamp TIME ZONE ls_ttzcu-tzonesys
          INTO DATE lv_system_date TIME lv_system_time.

UPDATE2: , , , :

    cl_abap_tstmp=>systemtstmp_utc2syst(
           EXPORTING  utc_tstmp = lv_utc_timestamp  
           IMPORTING  syst_date = lv_system_date    " System Date
                      syst_time = lv_system_time    " System Time
           ).
+5
1

:

cl_abap_tstmp=>systemtstmp_utc2syst(
       EXPORTING  utc_tstmp = lv_utc_timestamp  
       IMPORTING  syst_date = lv_system_date    " System Date
                  syst_time = lv_system_time    " System Time
       ).
+8

All Articles