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 - Character String Operator

One string operator is currently available for string expressions.

Other versions: 7.31 | 7.40 | 7.54

Syntax

... operand1 && operand2 ...

Effect

The chaining operator && concatenates two operands in a string expression as a 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 code has a character-like data type, can be specified. Furthermore, apart from built-in functions, generic expressions with non-character-like data types can be specified, which can be converted to the type string.

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 chaining in accordance with the associated predefined format.


Notes

  • String functions with character-like return codes are the best choice when specifying built-in functions as operands.

  • The chaining operator && must not be confused with the literal operator &, which joins two character literals as a literal. The literal operator is generally used if a literal string template 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 character string expression with a chaining 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 the right side of an assignment appends strings 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 a subtotal. Care must be taken to preserve this optimization, especially in loops.

Example

Concatenation of four operands as the character string "Hello world!". The last operand is a string template that has only literal content.

DATA text TYPE string VALUE `Hello`. 

text  = text && ` ` &&  'world' && |!|.

Example

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

ASSERT `` && -1 
     = `` && |{ -1 }|. 

ASSERT `` && -1 
    <> `` && CONV string( -1 ).