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, Upper/Lower Case

The example demonstrates the specification of upper/lower case for embedded expressions.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA: result  TYPE string,
          cldescr  TYPE REF TO cl_abap_classdescr,
          formats TYPE abap_attrdescr_tab,
          format  LIKE LINE OF formats.

    FIELD-SYMBOLS <case> LIKE cl_abap_format=>c_raw.

    cldescr ?= cl_abap_classdescr=>describe_by_name( 'CL_ABAP_FORMAT' ).
    formats = cldescr->attributes.
    DELETE formats WHERE name NP 'C_*' OR is_constant <> 'X'.

    LOOP AT formats INTO format.
      ASSIGN cl_abap_format=>(format-name) TO <case>.

      result = |{ format-name WIDTH = 20 }| &
               |{ `UPPER CASE, lower case ` CASE = (<case>) }|.
      WRITE / result.
    ENDLOOP.

Description

The three possible settings for the upper/lower case of a character string template are dynamically specified.