ABAP Keyword Documentation → ABAP  Reference → Declarations → Declaration Statements → Data Types and Data Objects → Declaring Data Types → TYPES
TYPES  TYPE abap_type
Other versions: 7.31  7.40  7.54
Syntax
TYPES { {dtype[(len)] TYPE abap_type [DECIMALS dec]}
 {dtype TYPE abap_type [LENGTH len] [DECIMALS dec]} }.
Addition
Effect
If a predefined data
type abap_type
is specified, a nongeneric elementary data type is defined. For abap_type
, all
predefined data types can be used except the internal types b
and s
.
In the ABAP types c
, n
, p
,
and x
, the length of the data type dtype
must be specified by entering directly a number or a 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 predefined ABAP types and no length can be specified in len
.
The length len
is either specified in parentheses directly after the type
name dtype
, or after the addition LENGTH
. The specified length must be positive.
Notes
 It is not necessary to list all additions in obsolete variants of the above statement. These additions are added implicitly.

For reasons of legibility, it is best to always use the addition
LENGTH
, and not parentheses, to specify the lengthlen
.
Example
These statements create three elementary data types that are local to the program. Values for the unspecified
technical properties of the predefined types c
and p
are specified.
TYPES: text10 TYPE c LENGTH 10,
text20 TYPE c LENGTH 20,
number TYPE p LENGTH 8 DECIMALS 2.
Addition
... DECIMALS dec
Effect
In the ABAP type p
, the number of
decimal places must
be specified using the addition DECIMALS
and by specifying a signless 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 decimal places or digits calculated from 2 * len  1, a warning is produced by the syntax check. 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 involving packed numbers, the
program attribute
fixed point arithmetic must be set. Otherwise, the addition DECIMALS
only affects the output on dynpros and the format for the statement WRITE [TO]
.
Note
If the number of decimal places is greater than the number of digits, the decimal separator is outside the sequence of digits, which has consequences in assignments and in output.
Example
Defines a numeric type for a packed number with three digits and two decimal places. The value range is 9.99 +9.99 in increments of 0.01.
TYPES number TYPE p LENGTH 2 DECIMALS 2.
Example
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.
TYPES number TYPE p LENGTH 2 DECIMALS 5.