ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Attributes of Data Objects
RTTS - Runtime Type Services
The RTTS are implemented through a hierarchy of type description classes that contain the methods for RTTC (Runtime Type Creation) and RTTI (Runtime Type Identification). With the help of these system classes it is possible
- to determine type information of existing instances and type names of the ABAP type systemat runtime.
- 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 description objects. For each type there is exactly one type description object. The attributes of the type description 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 description class with special attributes for special type properties. The class hierarchy of the type description classes corresponds to the hierarchy of the type kinds in the ABAP type system.
In addition, type description classes for complex types, references, classes, and interfaces have special methods for specifying references to partial types. These methods can be used can navigate to all partial types using a composite type.
Type description objects can only be created using the methods of type description classes. To get a reference to a type description object of a type, the static methods of the class CL_ABAP_TYPEDESCR can be used or call methods of the special type description classes.
Note
In the statement CREATE DATA
,
type description objects can be specified after the addition HANDLE
to create data objects with dynamically created data types.
Hierarchy of Type Description 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 for 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: / 'type name:', descr_ref->absolute_name.
WRITE: / 'kind :', descr_ref->type_kind.
WRITE: / 'length :', descr_ref->length.
WRITE: / 'Decimals:', descr_ref->decimals.