Mentor SAP
This method returns a description object with which the name of the type is known. It can analyse both data types and object types. It is unimportant whether the type was defined globally in the dictionary or class Builder, or locally in the program. You must enter the type name in Upper case. If the method does not find the type with the specified name, it raises a classic exception TYPE_NOT_FOUND.

 

 

 

 

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.