Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Attributes of Data Objects 

RTTS - Run Time Type Services

The RTTS are implemented through a hierarchy of type classes that contain the methods for RTTC (Run Time Type Creation) and RTTI (Run Time Type Identification). With the help of these system classes it is possible

  • To define new data types at runtime.

Other versions: 7.31 | 7.40 | 7.54

Concept

The properties of the types are represented by the attributes of type objects. For each type there is exactly one type object. The attributes of the type object contain information on the properties of the type. For each kind of type (elementary type, table, class, and so on), there is a type class with special attributes for special type properties. The class hierarchy of the type classes corresponds to the hierarchy of the type kinds in the ABAP type system.

In addition, type classes for complex types, references, classes, and interfaces have special methods for specifying references to partial types. With these methods, you can navigate to all partial types via a composite type.

Type objects can only be created through the methods of type classes. To get a reference to a type object of a type, you can use the static methods of the class CL_ABAP_TYPEDESCR or call methods of the special type classes.


Note

In the statement CREATE DATA, you can specify type objects after the addition HANDLE to create data objects with dynamically created data types.

Hierarchy of Type Classes

CL_ABAP_TYPEDESCR
  |
  |--CL_ABAP_DATADESCR
  |   |
  |   |--CL_ABAP_ELEMDESCR
  |   |--CL_ABAP_REFDESCR
  |   |--CL_ABAP_COMPLEXDESCR
  |       |
  |       |--CL_ABAP_STRUCTDESCR
  |       |--CL_ABAP_TABLEDESCR
  |
  |--CL_ABAP_OBJECTDESCR
     |
     |--CL_ABAP_CLASSDESCR
     |--CL_ABAP_INTFDESCR

Example of RTTI

REPORT typedescr_test.

TYPES my_type TYPE i.

DATA: my_data   TYPE my_type,
      descr_ref TYPE ref to cl_abap_typedescr.

START-OF-SELECTION.
  descr_ref = cl_abap_typedescr=>describe_by_data( my_data ).

  WRITE: / 'Typename:', descr_ref->absolute_name.
  WRITE: / 'Kind    :', descr_ref->type_kind.
  WRITE: / 'Length  :', descr_ref->length.
  WRITE: / 'Decimals:', descr_ref->decimals.

Continue

Ascertaining Data Types

Ascertaining Object Types