Determine Data Type Implicitly
1. CREATE DATA dref
[area_handle].
Determine Data Type using Predefined ABAP Types
2. CREATE DATA dref [area_handle]
TYPE {abap_type|(name)}
[LENGTH len] [DECIMALS dec].
Determine Data Type using Available Type
3. CREATE DATA dref
[area_handle]
{ {TYPE [LINE OF] {type|(name)}}
| {LIKE [LINE OF] dobj} }.
Create Data with Reference to a Type Object
4. CREATE DATA dref
[area_handle]
TYPE HANDLE handle.
Create Reference Variables
5. CREATE DATA dref
[area_handle]
TYPE REF TO {type|(name)}.
Create Internal Tables
6. CREATE DATA dref
[area_handle]
{ {TYPE tabkind OF [REF TO] {type|(name)}}
| {LIKE tabkind OF dobj} }
[WITH key]
[INITIAL SIZE n].
The CREATE DATA statement creates an anonymous data object and assigns the reference to the data object of the dref reference variables.
By default, the data object is created in the internal session of the current program and remains there for as long as it is required. If it is no longer referenced by reference variables, it is deleted by the garbage collector. The data object can be created as a shared object using the addition area_handle.
The dref reference variable has to be declared as a data reference variable. The content of a data object that is created with CREATE DATA can only be accessed using dereferenced data variables or field symbols (see data objects in operand positions).
The data type of the data object that is created can be defined using the TYPE addition and a type specification or with the LIKE addition and the specification of a data object. The syntax permits the dynamic definition of elementary data types, reference types and table types. The HANDLE addition can reference any RTTS type objects. According to the rules in section Assignments between Data Reference Variables, the static type of the data reference variables has to be more general than the data type of the data object created, or be identical with it.
If a treatable exception occurs as the object is being created, the object is not created and the dref data reference variable retains its previous state.
Unlike the DATA statement,
CREATE DATA creates the data object at execution time.
DATA creates declared data objects when the corresponding program unit is loaded.
Catchable Exceptions
CX_SY_CREATE_DATA_ERROR
Non-Catchable Exceptions