Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Built-In Types, Data Objects, Functions, and Constructors →  Predefined Data Types 

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 object, all generic types can be used after TYPE for the typing of field symbols and formal parameters. 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.

Type Description
any Any data type
any table Internal table with any table type
c Text field with a generic length
clike Character-like (c, n, and string plus the date/time types d, t and character-likeflat structures)
csequence Text-like (c, string)
data Any data type
decfloat Decimal floating point number (decfloat16, decfloat34)
hashed table Hashed table
index table Index table
n Numeric text with generic length
numeric Numeric ((b, s), i,int8, p, decfloat16, decfloat34, f)
object Any object type (root class of the inheritance hierarchy)
p Packed number with generic length and generic number of decimal places
simple Elementary data type including enumerated types and structured types with exclusively character-like flat components
sorted table Sorted table
standard table Standard table
table Standard table
x Byte field with generic length
xsequence Byte-like (x, xstring)

A typing with the generic type data works like a typing with the generic type any, with the following exception: No numeric functions, description functions, or arithmetic functions 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 table 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.

Other versions: 7.31 | 7.40 | 7.54


Notes

  • When generic types are used for the typing of field symbols and formal parameters, it must be ensured that the correct results are obtained regardless of the actual type being used. For example, if csequence is used, the potential fixed types c and string must display different behavior with respect to trailing blanks or the potential numeric types in calculations for numeric must 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 data and object), the generic type anycan only be specified directly after TYPE. any cannot be specified after TYPE REF TO. The only generic types allowed here are data for fully generic data reference variables and object for fully generic object reference variables. Specifying REF TO any would define a fully generic reference variable covering data references and object references. This is not currently possible.

  • The generic type object can only be specified after REF TO and not directly after TYPE.

  • The object type object plays 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 object can 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 object as a generic type.

  • Note with generic type p that when passing functional methods or arithmetic expressions to this type of typed input parameters, the length is always set to 16. With generic types numeric, simple and data or any, this is only the case for arithmetic expressions.

  • The elementary data type utclong is incorporated only by the generic types simple, data, and any.

Example

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).

METHODS numeric_operation IMPORTING num1          TYPE numeric
                                    num2          TYPE numeric
                          RETURNING VALUE(result) TYPE decfloat34.