Show TOC

Creating Data Objects DynamicallyLocate this document in the navigation structure

All of the data objects that you define in the declaration part of a program using statements such as DATA are created statically, and already exist when you start the program. To create a data object dynamically during a program, you need a data reference variable and the following statement:

CREATE DATA dref {TYPE type}|{LIKE dobj}.

This statement creates a data object in the internal session of the current ABAP program. After the statement, the data reference in the data reference variable dref points to the object. The data object that you create does not have its own name. You can only address it using a data reference variable. To access the contents of the data object, you must dereference the data reference .

You must specify the data type of the object using the TYPEor LIKE addition. In contrast to the use of the TYPEaddition in other ABAP statements, you can use the CREATE DATA addition to dynamically specify the data type as the contents of a field.

CREATE DATA dref TYPE (name).

Here, name is the name of a field that contains the name of the required data type.