CL_ABAP_TYPEDESCR
CL_ABAP_STRUCTDESCR
CL_ABAP_TABLEDESCR
DATA : lr_data TYPE REF TO data,
lr_line TYPE REF TO data,
lr_typedescr TYPE REF TO cl_abap_typedescr,
lr_structdescr TYPE REF TO cl_abap_structdescr,
lr_tabledescr TYPE REF TO cl_abap_tabledescr.
FIELD-SYMBOLS : <ft_table> TYPE STANDARD TABLE.
lr_typedescr = cl_abap_structdescr=>describe_by_name( gv_tabname ).
lr_structdescr ?= lr_typedescr.
lr_tabledescr = cl_abap_tabledescr=>create( lr_structdescr ).
CREATE DATA lr_data TYPE HANDLE lr_tabledescr.
ASSIGN lr_data->* TO <ft_table> CASTING TYPE HANDLE lr_tabledescr.
CREATE DATA
Syntax Forms
Defines the data type implicitly
1. CREATE DATA dref [area_handle].
Defines the data type using built-in ABAP types
2. CREATE DATA dref [area_handle]
TYPE {abap_type|(name)}
[LENGTH len] [DECIMALS dec].
Defines the data type using an existing type
3. CREATE DATA dref [area_handle]
{ {TYPE [LINE OF] {type|(name)}}
| {LIKE [LINE OF] dobj} }.
Creates data with reference to a type description object
4. CREATE DATA dref [area_handle]
TYPE HANDLE handle.
Creates reference variables
5. CREATE DATA dref [area_handle]
TYPE REF TO {type|(name)}.
Creates internal tables
6. CREATE DATA dref [area_handle]
{ {TYPE [STANDARD]|SORTED|HASHED TABLE
OF [REF TO] {type|(name)}}
| {LIKE [STANDARD]|SORTED|HASHED TABLE OF dobj} }
[ {WITH [UNIQUE|NON-UNIQUE]
{KEY {comp1 comp2 ...}|(keytab)}|{DEFAULT KEY}}
| {WITH EMPTY KEY} ]
[INITIAL SIZE n].
Effect
The statement CREATE DATA 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 (heap) of the current program and remains there for as long as it is required. If no data references and no field symbols point to the data object or to a part of the data objects, it is deleted by the garbage collector. The data object can be created as a shared object using the addition area_handle.
The reference variable dref must be declared as a data reference variable. The content of a data object created using 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 addition TYPE and specifying a type or using the addition LIKE and specifying a data object. The syntax permits the dynamic definition of elementary data types, reference types, and table types. The addition HANDLE can reference any RTTS type description objects. According to the rules in the 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 handleable exception is raised when the object is being created, the object is not created and the dref data reference variable keeps its previous state.
Notes
- Unlike the statement DATA, CREATE DATA creates the data object at execution time. DATA creates declared data objects when the corresponding program unit is loaded.
- The statement CREATE DATA creates a heap reference. All references that point to the anonymous data object or its parts are also heap references and keep the data object alive. The same applies to field symbols.
- When a data type is used, the instance operator NEW acts like the statement CREATE DATA dref TYPE type and can be used in general expression positions.
- Unlike CREATE OBJECT, CREATE DATA does not set the return code sy-subrc.
Handleable Exceptions
- Cause: Illegal value for the addition DECIMALS.
Runtime error: CREATE_DATA_ILLEGAL_DECIMALS - Cause: Illegal value for the addition INITIAL SIZE.
Runtime error: CREATE_DATA_ILLEGAL_INIT_SIZE - Cause: Illegal value for the addition LENGTH.
Runtime error: CREATE_DATA_ILLEGAL_LENGTH - Cause: The addition LENGTH was used for a type other than c, n, x, or p.
Runtime error: CREATE_DATA_LEN_NOT_ALLOWED - Cause: The type specified dynamically in the addition TYPE is not typed in full.
Runtime error: CREATE_DATA_NOT_ALLOWED_TYPE - Cause: The type specified dynamically in the addition TYPE is not known.
Runtime error: CREATE_DATA_UNKNOWN_TYPE
Non-Handleable Exceptions
- Cause: The variable dref does not have the correct type.
Runtime error: CREATE_DATA_REFERENCE_EXPECTED
CREATE DATA
Syntax
CREATE DATA dref [area_handle].
Defines the data type using built-in ABAP types
2. CREATE DATA dref [area_handle]
TYPE {abap_type|(name)}
[LENGTH len] [DECIMALS dec].
Defines the data type using an existing type
3. CREATE DATA dref [area_handle]
{ {TYPE [LINE OF] {type|(name)}}
| {LIKE [LINE OF] dobj} }.
Creates data with reference to a type description object
4. CREATE DATA dref [area_handle]
TYPE HANDLE handle.
Creates reference variables
5. CREATE DATA dref [area_handle]
TYPE REF TO {type|(name)}.
Creates internal tables
6. CREATE DATA dref [area_handle]
{ {TYPE [STANDARD]|SORTED|HASHED TABLE
OF [REF TO] {type|(name)}}
| {LIKE [STANDARD]|SORTED|HASHED TABLE OF dobj} }
[ {WITH [UNIQUE|NON-UNIQUE]
{KEY {comp1 comp2 ...}|(keytab)}|{DEFAULT KEY}}
| {WITH EMPTY KEY} ]
[INITIAL SIZE n].
Effect
The statement CREATE DATA 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 (heap) of the current program and remains there for as long as it is required. If no data references and no field symbols point to the data object or to a part of the data objects, it is deleted by the garbage collector. The data object can be created as a shared object using the addition area_handle.
The reference variable dref must be declared as a data reference variable. The content of a data object created using 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 addition TYPE and specifying a type or using the addition LIKE and specifying a data object. The syntax permits the dynamic definition of elementary data types, reference types, and table types. The addition HANDLE can reference any RTTS type description objects. According to the rules in the 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 handleable exception is raised when the object is being created, the object is not created and the dref data reference variable keeps its previous state.
Notes
- Unlike the statement DATA, CREATE DATA creates the data object at execution time. DATA creates declared data objects when the corresponding program unit is loaded.
- The statement CREATE DATA creates a heap reference. All references that point to the anonymous data object or its parts are also heap references and keep the data object alive. The same applies to field symbols.
- When a data type is used, the instance operator NEW acts like the statement CREATE DATA dref TYPE type and can be used in general expression positions.
- Unlike CREATE OBJECT, CREATE DATA does not set the return code sy-subrc.
Handleable Exceptions
- Cause: Illegal value for the addition DECIMALS.
Runtime error: CREATE_DATA_ILLEGAL_DECIMALS - Cause: Illegal value for the addition INITIAL SIZE.
Runtime error: CREATE_DATA_ILLEGAL_INIT_SIZE - Cause: Illegal value for the addition LENGTH.
Runtime error: CREATE_DATA_ILLEGAL_LENGTH - Cause: The addition LENGTH was used for a type other than c, n, x, or p.
Runtime error: CREATE_DATA_LEN_NOT_ALLOWED - Cause: The type specified dynamically in the addition TYPE is not typed in full.
Runtime error: CREATE_DATA_NOT_ALLOWED_TYPE - Cause: The type specified dynamically in the addition TYPE is not known.
Runtime error: CREATE_DATA_UNKNOWN_TYPE
Non-Handleable Exceptions
- Cause: The variable dref does not have the correct type.
Runtime error: CREATE_DATA_REFERENCE_EXPECTED