SAP STRING TEMPLATES EXPRESSIONS



Get Example source ABAP code based on a different SAP table
  


• { } ABAP_STRING_TEMPL

ABAP_STRINGTMPL - embedded_expressions

ABAP_SYNTAX
{ embd_exp $[format_options $] }

What does it do?
Within a string template, an opening and a closing curly bracket { ... } define a general expression position, embd_exp, at which the following can be specified in ABAP syntax:
Data objects
Calculation expressions
Constructor expressions
Table expressions
Built-in functions
Functional methods and method chainings
At least one blank must be included on the right of the opening bracket and one the left of the closing bracket. An embedded expression must be complete within the current string template. An embedded expression within the curly brackets is handled in accordance with regular ABAP syntax:
Tokens must be separated by at least one blank or line break.
In other cases, blanks and line breaks between tokens are not significant.
No distinction is made between uppercase and lowercase letters.
Comments can be specified.
The data type of the expression must be an elementary data type and the value of the expression must be character-like or be convertible to a character string. When a string template is evaluated, the value of each embedded expression is converted to a character string and inserted at the corresponding position. The string is formatted either using
Predefined formats
Formatting options format_options
The embedded expressions in a string template are evaluated from left to right. If functional methods are specified, they are executed during the analysis.



Latest notes:

To display the curly brackets { and } in the literal text of a string template, they must be prefixed with the escape character .
Curly brackets cannot be nested directly. If embd_expr is itself a string expression, or contains a string expression, it can also contain embedded expressions.
String functions with character-like return values are particularly suited when embedded functions are specified.
Unlike arithmetic expressions and bit expressions, embedded functional methods are not executed before the entire expression is evaluated. If an embedded functional method modifies the value of data objects that are also used as embedded operands, the change only affects data objects on the right of the method.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The string template in the method main uses embedded expressions to represent the text Hello world!. The first embedded expression is the attribute attr of the class. The return value of the method func is used in the second embedded expression. The third embedded expression is again the attribute attr, whose value has been changed in the method func in the meantime. The second embedded expression includes a line break and a comment is specified.
ABEXA 01310
ABAP_EXAMPLE_END