Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Character String and Byte String Processing →  Expressions and Functions for String Processing →  string_exp - String Expressions →  string_exp - String Templates →  Examples of string templates 

Character String Templates, Time Stamp Formats

The example demonstrates the various time stamp formats for embedded expressions.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA: land  TYPE t005x-land,
          datfm TYPE t005x-datfm.

    DATA: utc_long    TYPE utclong,
          time_stampl TYPE timestampl,
          time_stamp  TYPE timestamp.

    setup( ).

    utc_long    = utclong_current(  ).
    time_stamp  = cl_abap_tstmp=>utclong2tstmp_short( utc_long ).
    time_stampl = cl_abap_tstmp=>utclong2tstmp( utc_long ).

    SELECT land, datfm
           FROM t005x
           WHERE land LIKE '@%'
           INTO (@land,@datfm).

      result_tab =
        VALUE #( BASE result_tab
                 ( col1 = datfm
                   col2 = |{ utc_long    COUNTRY  = land
                                        TIMEZONE = sy-zonlo }|
                   col3 = |{ time_stampl COUNTRY  = land
                                        TIMEZONE = sy-zonlo }|
                   col4 = |{ time_stamp  COUNTRY  = land
                                        TIMEZONE = sy-zonlo }| ) ).
    ENDSELECT.

    teardown( ).

    display( ).

Description

Time stamps in time stamp fields and in packed numbers are produced in all possible country-specific date formats and time formats by using the parameter COUNTRY. For this purpose, the utility methods setup and teardown insert temporary rows with the possible values of the column DATFM into the database table T005X and are delete them again once they have been used. The value of the column TIMEFM can be entered on the selection screen.