
"Retrieving an UTC time stamp using the built-in function utclong_current
"The return value has the type utclong.
"e.g. 2024-01-01 15:45:46.2695940
DATA(ts1) = utclong_current( ).
"Using XCO
"Notes:
"- The results of the following chained statements are of type string.
"- With the 'as' method, a given format (available via xco_cp_time=>format)
" is applied to the time. Several options are available.
"- The 'moment' method has an optional importing parameter for specifying the
" time zone. By default, the user's time zone is used. For the specification,
" you can use xco_cp_time=>time_zone.
"The following three examples
"- do not specify the optional importing parameter for the 'moment' method. In
" this case, the user time zone is used implicitly.
"- specify a specific format in the 'as' method.
"e.g. 20250101162319
DATA(ts_abap) = xco_cp=>sy->moment( )->as( xco_cp_time=>format->abap )->value.
"e.g. 20250310T162320
DATA(ts_basic) = xco_cp=>sy->moment( )->as( xco_cp_time=>format->iso_8601_basic )->value.
"e.g. 2025-01-01T16:23:20
DATA(ts_ext) = xco_cp=>sy->moment( )->as( xco_cp_time=>format->iso_8601_extended )->value.
"Specifying the time zone explicitly in the 'moment' method
"The following method call retrieves the current user time stamp.
DATA(ts_user_tz) = xco_cp=>sy->moment( xco_cp_time=>time_zone->user
)->as( xco_cp_time=>format->iso_8601_basic
)->value.
"Specifying the UTC time zone
DATA(ts_utc_tz) = xco_cp=>sy->moment( xco_cp_time=>time_zone->utc
)->as( xco_cp_time=>format->iso_8601_basic
)->value.
Serkan AKKAVAK
Computer Engineer BSc
Head of SAP & Software Department
Contact : serkurumsal@yandex.com
0 Comments