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 

String Templates, Date Formats

This example demonstrates the various date formats for embedded expressions.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA: BEGIN OF result,
                  datfm  TYPE string,
                  format TYPE string,
                  result TYPE string,
                END OF result,
                results LIKE TABLE OF result.

    setup( ).

    SELECT land, datfm
           FROM t005x
           WHERE land LIKE '@%'
           ORDER BY PRIMARY KEY
           INTO (@DATA(land),@DATA(datfm)).
      result-datfm = datfm.
      READ TABLE fixvals WITH KEY low = datfm
           TRANSPORTING ddtext INTO fixval.
      IF sy-subrc = 0.
        result-format = fixval-ddtext.
      ELSE.
        CLEAR result-format.
      ENDIF.
      result-result = |{ sy-datum COUNTRY = land }|.
      APPEND result TO results.
    ENDSELECT.

    teardown( ).

    cl_demo_output=>display( results ).

Description

The current date is displayed in all possible country-specific date formats 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.