SAP UNTYPED NUMBER LITERALS



Get Example source ABAP code based on a different SAP table
  



Numeric Literals

ABAP_SYNTAX
... $[+$|-$]n$[n$[n$[...$]$]$] ...

What does it do?
A numeric literal consists of a continuous sequence of up to 31 digits n (0 to 9), which can be directly preceded by a plus (+) or minus (-) sign.
Numeric literals between -2147483648 and 2147483647 are integer literals and have the built-in ABAP type i.
Numeric literals outside of this interval are packed number literals and have the built-in 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 have between 16 and 31 digits.



Latest notes:

There are no numeric literals of type int8. The conversion operator CONV can be used to convert a numeric literal to the type int8.
Packed number literals have a different internal representation from integer literals. They cannot be cast directly on field symbols with the data type integer.
In numeric literals, no decimal separators or scientific notation with mantissa and exponent are possible.
Numbers that cannot be represented as numeric literals can only be specified in character literals. If they are used in operand positions in which a numeric value is expected, they are converted into these. The conversion operator CONV is recommended for targeted conversions.
Numeric literals that span multiple lines are not allowed. Furthermore, the literal operator cannot be used to create a composite literal from multiple numeric literals.
A numeric literal +$|-literal directly prefixed with a plus or minus sign must not be confused with a simple arithmetic expression +$|- literal for which there is a space between the operator +$|- and an unsigned literal. Unlike the numeric literal, the expression is not evaluated until runtime. Therefore, in such cases, the numeric literal should always be used for performance reasons.
NON_V5_HINTS
ABAP_HINT_END


ABAP_EXAMPLE_VX5
The first literal is of the type i. The following literals are of the type p with lengths 8 and 16.
ABEXA 01369
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
Targeted conversion of a character literal into type int8.
ABEXA 01370
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The example shows that a casting of a packed number literal to the type int8 has a different result than when using a field of the type int8, due to the different internal representation. If the field symbol < fs2> were typed with the time stamp type utclong, an exception would even be raised for the use in the embedded expression of the output.
ABEXA 01371
ABAP_EXAMPLE_END