SAP RTTI



Get Example source ABAP code based on a different SAP table
  


VERSION 5 IN
• CL_ABAP_TYPEDESCR ABAP_CLASS
• CL_ABAP_DATADESCR ABAP_CLASS
• CL_ABAP_ELEMDESCR ABAP_CLASS
• CL_ABAP_REFDESCR ABAP_CLASS
• CL_ABAP_COMPLEXDESCR ABAP_CLASS
• CL_ABAP_STRUCTDESCR ABAP_CLASS
• CL_ABAP_TABLEDESCR ABAP_CLASS
• CL_ABAP_OBJECTDESCR ABAP_CLASS
• CL_ABAP_CLASSDESCR ABAP_CLASS
• CL_ABAP_INTFDESCR ABAP_CLASS
• CL_ABAP_ENUMDESCR ABAP_CLASS

Runtime Type Services ( ABAP_RTTS )
The RTTS are implemented using a hierarchy of type description classes that contain the methods for Runtime Type Creation (RTTC) and Runtime Type Identification (RTTI). Using these system classes, it is possible to
determine type information of existing instances and type names in the ABAP type hierarchy at runtime.
define new data types at runtime.

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 about the properties of the type. For each type category (elementary type, table, class, and so on), there is a type description class with special attributes for the special type properties. The class hierarchy of the type description classes corresponds to the hierarchy of the type categories in the ABAP type hierarchy.
In addition, type description classes for complex types, references, classes, and interfaces have special methods for determining 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 methods of the special type description classes can be called.



Latest notes:

The RTTS type description classes use constants to refer to data types.
NON_V5_HINTS
The value of these constants corresponds to the single character IDs returned by statement DESCRIBE FIELD. A mapping of the constants to these IDs is listed for the addition ABAP Addition statement.
In the statement CREATE DATA, type description objects can be specified after the addition HANDLE to create data objects with dynamically created data types.
ABAP_HINT_END

Hierarchy of Type Description Classes
CL_ABAP_TYPEDESCR
|
|--CL_ABAP_DATADESCR
| |
| |--CL_ABAP_ELEMDESCR
| | |
| | |--CL_ABAP_ENUMDESCR
| |
| |--CL_ABAP_REFDESCR
| |--CL_ABAP_COMPLEXDESCR
| |
| |--CL_ABAP_STRUCTDESCR
| |--CL_ABAP_TABLEDESCR
|
|--CL_ABAP_OBJECTDESCR
|
|--CL_ABAP_CLASSDESCR
|--CL_ABAP_INTFDESCR

ABAP_EXAMPLE_VX5
Reading of the type properties of an elementary type from a type object generated with the method DESCRIBE_BY_DATA.
ABEXA 01233
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
Reading of the properties of the components of a structure. The reference to the type object is assigned using a downcast to a reference variable of type CL_ABAP_STRUCTDESCR.
ABEXA 01234
ABAP_EXAMPLE_END