Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Declaring Data Objects →  Literals 

Literal Operator

Other versions: 7.31 | 7.40 | 7.54

Syntax


... { '...' & '...' [& '...' [...] ] } 
  | { ... & ... [& ... [...] ] } ...

Effect

The literal operator & can be used to join two character literals of the same type as a single character literal. These categories of literals cannot be mixed. In this way, the definition of one literal can span multiple program lines. The content of the resulting literal must match its type and its length must not exceed the associated maximum length.

The literal operator can normally be used to join literals in any reading position. Exceptions to this are literals specified dynamically in parentheses, literals in parenthesized lists separated by commas (here the only relevant operand position is WHERE IN) , and literals in embedded Native SQL .


Notes

  • As well as for character literals, the literal operator can also be used to join string templates.

  • Any trailing blanks in text field literals are respected by the literal operator.

  • When used for literals, the literal operator & must not be confused with the chaining operator && that can be used in string expressions to chain character-like operators. Literals are joined using the literal operator only once when a program is compiled. The chaining operator, on the other hand, executes a real operation at runtime and chains any number of character-like operands. The trailing blanks of operands with fixed lengths, in particular text field literals, are ignored.

  • Character literals joined using the literal operator & are subject to the upper limit of 255 characters. Longer character strings can only be concatenated at runtime, for example using the chaining operator &&.

Example

Constructs an HTML string from subliterals.

DATA html TYPE string. 

html = 
  `<html>`   & 
  `<body>`   & 
  `Text`     & 
  `</body>`  & 
  `</html>`. 

cl_abap_browser=>show_html( html_string = html ).