This method returns the description object for the type of a data object. It only returns descriptions of data types, but it does not matter whether the data object is defined with an explicit type or bound type. If the specified data object is a parameter or field symbol with a generic type, the method does not return the description of the generic type. Instead, it returns the type of the currently assigned actual parameter or data object.
This method returns the description object for the type of a data object that a data reference points to. It only returns descriptions of data types. If the data reference is typed generically( TYPE REF TO DATA ), you can use this method to determine the dynamic type of the referenced data object.
This method returns the description object for the type of an instance that an object reference points to. It only returns descriptions of classes. Use this method to determine the dynamic type of the referenced instance after an upcast to a superclass or implemented interface.
Describe Types Based on Data Objects and References
The figure shows an example of how to use these DESCRIBE_BY_xxx static methods.
In addition to the static methods listed, there is another option available for accessing description objects. Special methods are available to navigate from one description object to other description objects. For example, you want to navigate from the description of a table type to the description of the corresponding line type, or you want to navigate from a structure type to the description objects for the component types.
Elementary Data Type Analysis
The example in the figure demonstrates how to use RTTI to determine the properties of different data types, in this case, an elementary data type. The data type determines which subclass is used.
An instance of class CL_ABAP_ELEMDESCR describes all the properties of an elementary data type. The corresponding public attributes contain the technical properties of the underlying ABAP type, the length, and the number of decimal places. To evaluate the TYPE_KIND attribute, compare its contents with the corresponding constants from class CL_ABAP_TYPEDESCR, in the same way as for the KIND attribute.
The three attributes are described in the root class of RTTI, which means they are inherited by all description classes. However, in the other classes, these attributes are less significant.
The semantic properties, that is, the additional information from the ABAP Dictionary, must be determined explicitly using public methods. The figure shows a call of method GET_DDIC_FIELD. You can use an optional parameter to determine language-dependent information, such as field labels, in a language other than the current logon language.
Caution: If the current type is not a dictionary type, the method raises a classic exception. To avoid this, first use method IS_DDIC_TYPE to check whether dictionary information is available (see the example given in the figure).
Reference Type Analysis
When you analyze a reference type (= type of a reference variable), the inherited TYPE_KIND attribute allows you to differentiate between object references and data references. However, to determine the details of the static type of the reference variable, use the GET_REFERENCED_TYPE navigation method. This method returns a reference to another description object. This description object can be an instance of class CL_ABAP_STRUCTDESCR if the reference variable was created with a structure type. However, if the reference variable was created with reference to a class or an interface, then GET_REFERENCED_TYPE returns instances of the CL_ABAP_CLASSDESCR or CL_ABAP_INTFDESCR class, respectively.