SAP STRING OPERATORS



Get Example source ABAP code based on a different SAP table
  


• ABAP_STRING_OPERATOR

ABAP_STRINGEXP -

ABAP_SYNTAX ... operand1 operand2 ...

What does it do?
The concatenation operator concatenates two operands in a string expression into one character string.
The operand positions operand are enhanced character-like expression positions , which means that character-like data objects, string expressions, and built-in functions , or functional methods and method chainings whose return value has a character-like data type , can be specified. Furthermore, apart from built-in functions, generic expressions with non-character-like data types can also be specified, which can be converted to the type string. The operand operand must be elementary. Structures with character-like-only flat components cannot be specified.
In the case of character-like operands with a fixed length, trailing blanks are ignored. An operand that does not have a character-like data type is regarded implicitly as an embedded expression of a string template and formatted as a text string before the concatenation in accordance with the associated predefined format.



Latest notes:

In particular, string templates can be specified as operands.
String functions with character-like return values are particularly suitable when specifying built-in functions as operands.
The concatenation operator must not be confused with the literal operator , which combines two character literals to one literal. The literal operator is generally used if a literal is to be defined across multiple program lines. The operator is executed only once when the program is compiled, and trailing blanks of character literals are always respected. A string expression with a concatenation operator, on the other hand, is recalculated each time, like all expressions, and can be used to concatenate any number of character-like operands.
If on the right side of an assignment, strings are appended using to a variable specified with the type string on the left side of the assignment, the variable is used directly in some cases without producing an interim result. It should be ensured that this optimization is preserved, especially in loops.
It should be noted that the handling of non-character-like operands as embedded expressions can have different results than simple conversions .
A calculation assignment with the operator = can be used as a short form for assignments of concatenations.
NON_V5_HINTS
ABAP_HINT_END
BEGIN_SECTION SAP_INTERNAL_HINT
Internally, built-in functions that do not return character strings are handled as numeric expressions. Those cannot be mixed with string expressions.
END_SECTION SAP_INTERNAL_HINT

ABAP_EXAMPLE_VX5
Concatenation of four operands into the character string Hello world!. The last operand is a string template that has only literal content.
ABEXA 01303
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
This example demonstrates that a non-character-like operand in a concatenation is handled like an embedded expression and is not converted in accordance with the conversion rules. After handling as an embedded expression, the minus sign is placed to the left of the number. After the conversion, it is placed to the right of the number.
ABEXA 01304
ABAP_EXAMPLE_END