SAP Tutorials Blog


 


"Check the class documentation. More methods are available.

DATA(low_timestamp) = CONV utclong( '2024-01-01 05:30:00' ).
DATA(high_timestamp) = CONV utclong( '2024-01-03 10:35:12' ).

"'diff' method: Calculating time differences
cl_abap_utclong=>diff( EXPORTING high     = high_timestamp
                                 low      = low_timestamp
                       IMPORTING days    = DATA(diff_days) "2
                                 hours   = DATA(diff_hours) "5
                                 minutes = DATA(diff_minutes) "5
                                 seconds = DATA(diff_seconds) ). "12

"Converting a time stamp from a character-like format to utclong
"Creating a time stamp in a string
DATA(ts_string) = |{ utclong_current( ) TIMESTAMP = ENVIRONMENT TIMEZONE = 'UTC' }|.
TRY.
    cl_abap_utclong=>read( EXPORTING string   = ts_string
                                     timezone = 'UTC'
                           IMPORTING value    = DATA(utc_ts) ).
    CATCH cx_abap_utclong_invalid.
ENDTRY.



Serkan AKKAVAK Computer Engineer BSc Head of SAP & Software Department Contact : serkurumsal@yandex.com