Run Time Type Services
-
Upload
dineshkaushal -
Category
Documents
-
view
111 -
download
0
Transcript of Run Time Type Services
![Page 1: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/1.jpg)
SAP Global Delivery
Integration Services
Run Time Type Services (RTTS)
Pablo Rovira Bosch, SAP GD Buenos Aires03.11.2010
![Page 2: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/2.jpg)
© SAP 2010 / Page 2
RTTS (Run Time Type Services)
The RTTS ( Run Time Type Services) are implemented through a hierarchy of type classes that provides the following functionalities:
Type identification and description at run time (RTTI)
Dynamic type creation (RTTC)
Each type kind corresponds to one description class.
Each class has RTTI and RTTC methods
![Page 3: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/3.jpg)
RTTS Class hierarchy
© SAP 2010 / Page 3
CL_ABAP_TYPEDESCR
CL_ABAP_DATADESCR
CL_ABAP_REFDESCR
CL_ABAP_ELEMDESCR
CL_ABAP_COMPLEXDESCR
CL_ABAP_OBJECTDESCR
CL_ABAP_INTFDESCR
CL_ABAP_CLASSDESCR
CL_ABAP_STRUCTDESCR
CL_ABAP_TABLEDESCR
![Page 4: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/4.jpg)
RTTI & RTTC methods
Some examples of methods are:
• RTTI CL_ABAP_STRUCTDESCR->GET_COMPONENTS
Returns component description table of structure CL_ABAP_CLASSDESCR->GET_SUPER_CLASS_TYPE
Returns super class type CL_ABAP_ELEMDESCR->IS_DDIC_TYPE
Returns TRUE if it is a Dictionary type
• RTTC CL_ABAP_ELEMDESCR=>GET_C
Returns the Type Object for an Elementary Type c CL_ABAP_ELEMDESCR=>GET_N
Returns the Type Object for an Elementary Type n CL_ABAP_STRUCTDESCR=>CREATE
Factory method for Structure Type creation
© SAP 2010 / Page 4
![Page 5: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/5.jpg)
Type Object
To introduce us in the study and the usage of RTTS, we should know first what is a Type Object and its properties.
A Type Object:
Is an instance of a RTTS class.
Describe all properties of a type.
Can be used instead of type name.
There are 4 ways to get a type object using RTTC methods:
By type name (DESCRIBE_BY_NAME)
By data object (DESCRIBE_BY_DATA)
By object reference (DESCRIBE_BY_OBJECT_REF)
By data reference (DESCRIBE_BY_DATA_REF)
© SAP 2010 / Page 5
![Page 6: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/6.jpg)
Get a type object
By type name (DESCRIBE_BY_NAME)
By data object (DESCRIBE_BY_DATA)
© SAP 2010 / Page 6
![Page 7: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/7.jpg)
Get a type object
By object reference (DESCRIBE_BY_OBJECT_REF)
By data reference (DESCRIBE_BY_DATA_REF)
© SAP 2010 / Page 7
![Page 8: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/8.jpg)
RTTS - Usage
There are many possible scenarios where we can use RTTS and take advantage of it.
The following are some examples:
• RTTI usageGet field description from data dictionaryGet all the components of a structure and its properties
• RTTC usageCreate data objects dynamicallyCreate an internal table dynamically
© SAP 2010 / Page 8
![Page 9: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/9.jpg)
RTTI - Usage
Scenario:
You have defined a custom type structure whose fields are referenced to DDIC elements.
You need to get fields descriptions.
© SAP 2010 / Page 9
![Page 10: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/10.jpg)
RTTI - Usage
Output:
© SAP 2010 / Page 10
Structure DFIES contains all properties of a data dictionary element
![Page 11: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/11.jpg)
RTTI - Usage
Scenario:
You have defined a custom type structure.
You need to get component names.
© SAP 2010 / Page 11
![Page 12: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/12.jpg)
RTTI - Usage
Output:
© SAP 2010 / Page 12
Structure ABAP_COMPDESCR contains all properties of a data object: • Length• Decimals• Type kind• Name
![Page 13: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/13.jpg)
RTTC - Usage
Scenario:
You need to create an internal table dynamically.
© SAP 2010 / Page 13
In this example you can choose the internal table structure by using
the parameter P_TABLE
T_TABLE internal table of type T001T and GS_TABLE work area of type T001T are now created.
Let’s try to populate the internal table with data and print it.
![Page 14: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/14.jpg)
RTTC - Usage
© SAP 2010 / Page 14
![Page 15: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/15.jpg)
RTTC - Usage
The output of our test program will be a simple report showing the data on the internal table we created dynamically.
© SAP 2010 / Page 15
![Page 16: Run Time Type Services](https://reader035.fdocuments.in/reader035/viewer/2022081413/54706e5db4af9f050c8b45c9/html5/thumbnails/16.jpg)
© SAP 2008 / Page 16
Thank you!