Literals Locate the document in its SAP Library structure

Literals are unnamed data objects that you create within the source code of a program. They are fully defined by their value. You cannot change the value of a literal. There are two types of literals: numeric and character.

Number literals

Numeric literals are sequences of digits which may contain a plus or minus sign. They can represent any number within the valid range for the predefined ABAP type P with length 16, that is, a number of up to 31 digits plus a plus or minus sign. Numeric literals between -231+1 and 231-1 have the predefined ABAP type I. All other numeric literals have type P without decimal places. Numeric literals of up to 15 digits (plus their plus or minus sign) have a field length of 8 bytes, all others have a field length of 16 bytes.

Example

Examples of numeric literals:

123
-93
+456

Numeric literals in ABAP statements:

DATA number TYPE i VALUE -1234.

WRITE 6789.

MOVE 100 TO number.

If you want to use non-integer values or a longer number, you must use a character literal (data type C). The character literal in this case must have the format

'[<mantissa>][E][<exponent>]'

for floating point numbers. When you use character literals of this kind in ABAP statements, the system converts them into the corresponding numeric data type.

Example

Examples of character literals that can be converted into numeric types:

'12345678901234567890'
'+0.58498'
'-8473.67'
'-12.34567'
'-765E-04'
'1234E5'
'+12E+23'
'+12.3E-4'
'1E160'

Character Literals

Character literals are sequences of alphanumeric characters in the source code of an ABAP program enclosed in single quotation marks or backquotes. Character literals enclosed in quotation marks have the predefined ABAP type C and are described as text field literals. Literals enclosed in backquotes have the ABAP type STRING and are described as string literals. The field length is defined by the number of characters. With text field literals trailing blanks are ignored while in string literals they are taken into account.

Example

Examples of text field literals:

'Antony Smith'
'69190 Walldorf'

Examples of string literals:

`Anton Schmitt `
`69190 Walldorf `

Character literals can be up to 255 characters long. A text field literal is always at least one character long (entering ' is the equivalent of ‘). A string literal can also be empty (entering ` is the empty string with length zero ´).

If you want to enter a character literal in the ABAP Editor that is longer than a single editor line, ABAP syntax allows you to enter several character literals and link them using the & character. If a character literal contains a quotation mark or backquote, you must repeat it to enable the system to recognize the contents as a character literal and not as the end of the literal.

Example

WRITE: / 'This is John''s bicycle'.

WRITE: / `A backquote (``)`.

This statement generates the following output:

This is John's bicycle

A backquote (`)

 

 

Leaving content frame