title: How to convert an UTC timestamp to system date and time in ABAP
body: <p>does anyone of you have suggestions how to convert a given UTC timestamp into the date and time of the system time zone?</p>
  
  <p>Converting from an UTC timestamp to the users local time zone is easy, you could just do:</p>
  
  <pre><code>CONVERT TIME STAMP lv_utc_timestamp TIME ZONE sy-zonlo
            INTO DATE lv_local_date TIME lv_local_time.
  </code></pre>
  
  <p>But how to do it for the system time - system time is needed in many situations e.g. when calling the JOB_CLOSE function module. The only solution I have come up so far is like that:</p>
  
  <pre><code>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.
  </code></pre>
  
  <p>Is this already the best solution or can the system time zone be retrieved in another way?
  Is there always a valid time zone to be expected from the entry in table TTZCU? Any ideas?</p>
  
  <p><strong>UPDATE:</strong> @rmtiwari suggested on twitter, that the FLAGACTIVE flag of TTZCU should also be checked, so the modified statement would be </p>
  
  <pre><code>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.
  </code></pre>
  
  <p><strong>UPDATE2:</strong> I have found another way, which is probably the best:</p>
  
  <pre><code>    cl_abap_tstmp=&gt;systemtstmp_utc2syst(
             EXPORTING  utc_tstmp = lv_utc_timestamp  
             IMPORTING  syst_date = lv_system_date    " System Date
                        syst_time = lv_system_time    " System Time
             ).
  </code></pre>