SAP TYPES SIMPLE ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• LENGTH TYPES
• TYPE abap_type TYPES

TYPES, TYPE abap_type
Short Reference

ABAP_SYNTAX
TYPES ${ ${dtype$[(len)$] TYPE abap_type $[DECIMALS dec$]$}
$| ${dtype TYPE abap_type $[LENGTH len$] $[DECIMALS dec$]$}$}.

ABAP Addition
... DECIMALS dec

What does it do?
By specifying a built-in data type abap_type, a non-generic elementary data type is defined. For abap_type, all built-in data types can be used, except for the internal types b and s .
For the ABAP types c, n, p, and x, the length of the data type dtype must be specified by entering a number directly or by specifying a corresponding numeric constant len within the length range defined for the type in question. For all other ABAP types, the length is determined by the value in the tables of built-in ABAP types and no length can be specified in len.
The length len is specified either in parentheses directly after the type name dtype, or after the addition LENGTH. The specified length must be positive. If the length is not specified explicitly for the ABAP types c, n, p, and x , the standard length is defined implicitly.



Latest notes:

For reasons of legibility, it is best to always use the addition LENGTH instead of parentheses to specify the length len.
The non-specifiable internal types b and s can be achieved by referencing the built-in data types INT1 and INT2 in ABAP Dictionary.
NON_V5_HINTS
It is not necessary to list all additions in obsolete variants of the above statement since they are added implicitly.
ABAP_HINT_END

ABAP_EXAMPLE_VX5
These statements create three elementary data types that are local to the program. Values for the unspecified technical properties of the built-in types c and p are specified.
ABEXA 00741
ABAP_EXAMPLE_END
• DECIMALS TYPES

ABAP Addition

What does it do?
In the ABAP type p, the number of decimal places must be defined using the addition DECIMALS and by specifying an unsigned number directly or a corresponding numeric constant dec. The addition cannot be specified in other data types.
A maximum of 14 decimal places can be specified. If the number of decimal places is greater than the number of places or digits calculated from 2 * len - 1, a syntax check warning occurs. This is because only the last 2 * len - 1 decimal places can be filled with digits.
For the decimal separator to be respected in operations with packed numbers, the program property fixed point arithmetic must be set.
BEGIN_SECTION VERSION 5 OUT Otherwise, the addition DECIMALS only affects the output on dynpros and the format for the statement WRITE $[TO$].
END_SECTION VERSION 5 OUT



Latest notes:

If the number of decimal places is greater than the number of digits, the decimal separator is outside the sequence of digits, which should be respected in assignments and outputs. Such a number can raise exceptions in conversions to external formats such as data types of the database in AB_SQL or during serializations to asXML.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Definition of a numeric type for a packed number with three digits and two decimal places. The value range is -9.99 to +9.99 in increments of 0.01.
ABEXA 00742
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
Defines a numeric type for a packed number with three digits and five decimal places. This statement produces a syntax check warning. The value range is -0.00999 to +0.00999 in increments of 0.00001. Not all decimal places can be used.
ABEXA 01693
ABAP_EXAMPLE_END

Return to menu