16
SAP Global Delivery Integration Services Run Time Type Services (RTTS) Pablo Rovira Bosch, SAP GD Buenos Aires 03.11.2010

Run Time Type Services

Embed Size (px)

Citation preview

Page 1: Run Time Type Services

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

© 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

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

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

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

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

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

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

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

RTTI - Usage

Output:

© SAP 2010 / Page 10

Structure DFIES contains all properties of a data dictionary element

Page 11: Run Time Type Services

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

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

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

RTTC - Usage

© SAP 2010 / Page 14

Page 15: Run Time Type Services

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

© SAP 2008 / Page 16

Thank you!