Essential for data references is the addition
REF TO after
Dynamic Creation of Structures
If the type of a structure should be decided on runtime, we can define our target structure as reference to the generic type
DATA wa TYPE REF TO data.
wa a type we use the statement
CREATE DATA. The addition
TYPE can be specified by:
CREATE DATA wa TYPE kna1
- Static checks are active so it's not possible to create an unknown type
CREATE DATA wa TYPE (lw_name_as_string)
- The parentheses are needed and
lw_name_as_stringcontains the types name as string.
- If the type was not found, an exception of type
CX_SY_CREATE_DATA_ERRORwill be thrown
For instancing dynamically created types the
HANDLE addition can be specified.
HANDLE receives an object which inherits from
CREATE DATA dref TYPE HANDLE obj
objcan be created using the RunTime Type Services
drefis still a datareference, it has to be dereferenced (
->*) to be used as datacontainer (normally done via Field-Symbols)