Literals

There are two types of literals in the ABAP programming language: Character literals and numeric literals.

Character Literals

Character literals can be grouped into text field literals and string literals.

Text Field Literals

Text field literals are enclosed in single quotation marks (') and have the data type C.

If the quotation mark occurs in the middle of the character string, it must be duplicated: 'AB''CD'

An empty text field literal (''), that is, a literal that does not contain any characters is automatically set to a literal of length 1 with a blank as its content (' ').

Since text field literals have the data type C, closing blanks such as in assignments and VALUE specifications are ignored.

If one line is not sufficient, you can link several text field literals using the operator &.

Examples:
1. 'ABCD'
2. 'AB' & 'CD'
3. 'AB' &
   'CD'


All three options designate the same literal.

If a text field literal reaches the end of the line, it can be continued at the beginning of the next line. Since the editor converts the characters in the continuation line into upper case, you can only make restricted use of this feature.

In ABAP Objects, that is in classes and class pools, the syntax check made here is stricter. See Cannot Process a Literal Over Several Lines.

If a REPORT has lines containing more than 72 characters, cross-line literals cause an error during the syntax check if the last significant character is in the the first line right in the 72nd column. However, if the last significant character is in the first 72 columns, the syntax check, for compatibility reasons, only displays a warning. To ensure program safety it is better not to use cross-line literals, but instead construct long literals with the operator & (see above).

String Literals

String literals are enclosed in single back quotes (`) and have the data type STRING.

If the back quote occurs in the middle of the character string, it must be duplicated: `AB``CD`

An empty string literal (``), that is, a literal that does not contain any characters represents an empty string of zero length.

Since string literals have the data type STRING, closing blanks such as in assignments and VALUE specifications are considered.

If one line is not sufficient, you can link several string literals using the operator &.

String literals cannot extend over several lines.

Examples:
1. `ABCD`       " Length of 4 character
2. `ABCD `      " Length of 5 characters
3. `A``B` &
  `CD `        " Length of 6 characters


Numeric Literals

Numeric literals consist of numbers ("0" - "9"). These numbers may be preceded by a plus ("+") or minus sign ("-").

Numeric literals have the ABAP type I or P:

The maximum length for numeric literals is 31 places.
Numeric literals with a length of more than 31 decimal places are not allowed and trigger a syntax error.