CREATE DATA dref [area_handle]
TYPE HANDLE handle.
With the HANDLE addition, the CREATE DATA statement creates a data object whose data type is described by an RTTS type object. For handle, a reference variable of the static type of class CL_ABAP_DATADESCR or its subclasses has to be specified, which points to a type object. The type object may have been created by using the RTTS methods on existing data objects, or by the dynamic definition of a new data type.
The type object must describe a non-generic type. Only with type objects for the generic ABAP types
c, n, p and x, is a new
bound data type with the
default values created and used. Similarly with a type
object for a standard table with a generic table type, a new bound table type with a standard key is created and used.
Important methods for the dynamic definition of data types are:
Dynamic creation of a two-component structure using the CREATE method of the CL_ABAP_STRUCTDESCR class. The description of the components in the structure is provided in the comp_tab internal table.
DATA: struct_type TYPE REF TO cl_abap_structdescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
comp LIKE LINE OF comp_tab,
dref TYPE REF TO data.
FIELD-SYMBOLS: <struc> TYPE ANY,
<comp> TYPE ANY.
comp-name = 'column1'.
comp-type = cl_abap_elemdescr=>get_c( 40 ).
APPEND comp TO comp_tab.
comp-name = 'column2'.
comp-type = cl_abap_elemdescr=>get_i( ).
APPEND comp TO comp_tab.
struct_type = cl_abap_structdescr=>create( comp_tab ).
CREATE DATA dref TYPE HANDLE struct_type.
ASSIGN dref->* TO <struc>.
ASSIGN COMPONENT 'COLUMN1' OF STRUCTURE <struc> TO <comp>.
<comp> = 'Amount'.
ASSIGN dref->* TO <struc>.
ASSIGN COMPONENT 'COLUMN2' OF STRUCTURE <struc> TO <comp>.
<comp> = 11.