Generic ABAP Types
The following table shows the predefined generic ABAP types. A generic data type is an incomplete type
specification that includes multiple complete type specifications. With the exception of
all generic types can be used after
TYPE for the
field symbols and
When a data object is assigned to generically typed field symbols using the statement
ASSIGN, or when a data object is used as an
actual parameter for generically typed formal parameters for
procedure calls, the system checks whether the concrete data type is
compatible with the object (in other words, whether the data type is a subset of the generic type).
The only generic types that can be used after
TYPE REF TO are
data, for the generic typing of data references, and
object, for the generic typing of object references.
||Any data type|
||Internal table with any table type|
||Text field with a generic length|
||Any data type|
||Decimal floating point number (
||Numeric text with generic length|
||Any object type (root class of the inheritance hierarchy)|
||Packed number with generic length and generic number of decimal places|
||Elementary data type including enumerated types and structured types with exclusively character-like flat components|
||Byte field with generic length|
A typing with the generic type
data works like a typing with the generic type
any, with the following exception: No
description functions, or
can be passed to a formal parameter typed with the type
data. All other expressions, built-in functions, and functional methods are possible.
Besides the built-in generic types shown in the table above, ABAP at present includes exactly one kind of self-defined generic type. A
type defined with
TYPES - TABLE OF or defined in ABAP Dictionary is generic if the
primary table key is not defined or is incompletely defined or if the
secondary table key of the table type is generic.
- When generic types are used for the typing of
field symbols and
it must be ensured that the correct results are obtained regardless of the actual type being used. For
csequenceis used, the potential fixed types
stringmust display different behavior with respect to trailing blanks or the potential numeric types in calculations for
numericmust produce different calculation types. More specifically, when existing typings are generalized, it may be necessary to modify the implementation accordingly.
- Like all generic types mentioned here (except
object), the generic type
anycan only be specified directly after
anycannot be specified after TYPE REF TO. The only generic types allowed here are
datafor fully generic data reference variables and
objectfor fully generic object reference variables. Specifying
REF TO anywould define a fully generic reference variable covering data references and object references. This is not currently possible.
- The generic type
objectcan only be specified after
REF TOand not directly after
- The object type
objectplays a special role, because strictly speaking it is the empty root class of all object classes of ABAP Objects and is not a genuine generic type. An object reference variable typed using
REF TO objectcan point to any object because of the general reference variable property stating that reference variables with the static type of a superclass can point to objects in all related subclasses. When compared with a data reference variable typed using the real generic data type
data, which can point to any data object, it is perfectly possible to classify
objectas a generic type.
- Note with generic type
pthat when passing functional methods or arithmetic expressions to this type of typed input parameters, the length is always set to 16. With generic types
any, this is only the case for arithmetic expressions.
- The elementary data type
utclongis incorporated only by the generic types
Uses the built-in generic type
numeric to type the input parameters of a method. Parameters with any numeric data types can be passed to the method (but no other data types).
num2 TYPE numeric
RETURNING VALUE(result) TYPE decfloat34.