Ansicht
Dokumentation

ABENSTRING_TEMPLATES - STRING TEMPLATES

ABENSTRING_TEMPLATES - STRING TEMPLATES

CPI1466 during Backup   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

- String Templates ()

|$[literal_text$]$[ embedded_expressions$]$[control_characters$]|

Effect

A string template is enclosed by two characters "|" and creates a character string that is used by the string expression at the operand position of the string template. The characters in this character string are determined by any sequence of the following syntax elements of the string template:

A string template that starts with "|" must be closed with "|" within the same line of source code. The only exceptions to this rule are line breaks in embedded expressions. However, a string template is not subject to any length restrictions. The literal operator & or the concatenation operator && can be used to combine multiple string templates into a single string template. A string template can be defined across multiple lines of source code and be given comments.

Notes

  • To display the delimiters "|" within literal text of a string template, it must be prefixed with the escape symbol \.
  • The delimiter characters "|" can be formatted in the ABAP Editor by choosing Fonts and Colors → Token operator to highlight them in the source code.
  • Using the string function escape, all special characters for string templates can be put in front of their escape character.
  • When string templates are combined, the literal operator & behaves differently than with literals. This operator is executed at runtime in the same way as the concatenation operator && and not just once during compilation. This means, however, that the restriction of 255 characters for literals no longer applies. The two combinations
|...| &  |...|
|...| && |...|
are identical for string templates. For purely literal content, they are the same as
`...` && `...`
However, they are different to
`...` &  `...`
'...' &  '...'
'...' && '...'
In the first two cases, a length restriction of 255 characters applies. In the third case, trailing blanks are ignored.
  • If on the right side of an assignment, strings are appended to a variable specified with the type string on the left side of the assignment, the variable is used directly in specific cases without producing an interim result. It should be ensured that this optimization is not undone, especially in loops.

String template with literal text and an embedded expression. The result is made up of the content of the literal text and the result of the embedded expression.

The following section of source code shows three identical string templates, all of which represent the character string "Hello World!". The first string template contains the entire character string as literal text. The next two string expressions distribute the literal text across multiple parts of the string template and these are combined into the same character string using the literal operator & as in the first string template.






Fill RESBD Structure from EBP Component Structure   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.

Length: 5199 Date: 20240419 Time: 171641     sap01-206 ( 83 ms )