Literals

Besides the named data objects which can be addressed by their names in the ABAP program (this includes the text symbols) and the anonymous data objects created by the CREATE DATA statement, there are literals which are defined in the source code of a program and are fully qualified by their value. Possible literals are numeric literals and character literals. The character literals comprise text field literals and string literals (as of release 6.10).

Numeric Literals

Numeric literals consist of continuous sequences of numbers (0 to 9), which can be directly preceded by a plus (+) or minus (-) sign. Numeric literals between -2147483648 and 2147483647 have the predefined ABAP type i. Numeric literals outside of this interval have the predefined ABAP type p with a length of 8 bytes if they are not longer than 15 digits, and with a length of 16 bytes if they are not longer then 31 digits. Numeric literals with more than 31 digits are not possible.

In numeric literals, neither decimal separators nor scientific notation with mantissa and exponent are possible. To be able to represent numbers with fractional portion or numbers in scientific notation as a literal, you must use character literals. When using them at operand positions at which a numeric value is expected, they are converted accordingly. The same applies for numbers with more than 31 digits.

Text Field Literals

Text field literals are character strings included in single inverted commas ('). They have the data type c in the length of the included characters, including trailing blanks. There is no empty text field literals: The text field literal '' is identical to the text field literal ' ' of length 1.

To represent an inverted comma inside a text field literal, you must enter two consecutive inverted commas. The length of a text field literal must lie between 1 and 255 characters.

In the ABAP editor, you can use the character & (literal operator) to join several text field literals to one text field literal, even across several program lines.

If a text field literal is specified at an operand position at which a text symbol is possible, you can append the three-digit identifier ### of a text symbol in round brackets.

... 'Literal'(###) ...

If the text symbol exists in the currently loaded text pool, then the content of the text symbol is used instead of the literal, otherwise the literal is used.

String Literals

String literals are character strings included in single backquotes (`), which have the data type string. The empty string literal `` represents a string of length 0.

To represent a backquote within a string literal, you must enter two consecutive backquotes. A string literal can be up to 255 characters long. An empty string literal is identical to an empty string of length 0.

In the ABAP editor, you can use the character & (literal operator) to join several string literals to one string literal, even across several program lines.

Notes

Example

Representation of inverted commas and backquotes in literals. The first two and the last two literals always have the same meaning.

WRITE: / 'This is John's bike',
       / `This is John's bike`,
       / 'This is a backquote: `',
       / `This is a backquote: ```.