Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Creating Objects and Values →  CREATE DATA 

CREATE DATA - HANDLE

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


CREATE DATA dref [area_handle] 
                 TYPE HANDLE handle.

Effect

The statement CREATE DATA uses the addition HANDLE to create a data object whose data type is described by an RTTS type description object. handle expects a reference variable of the static type of class CL_ABAP_DATADESCR or its subclasses that points to a type description object. The type description object may have been created by applying the RTTS methods to existing data objects or by using the dynamic definition of a new data type.

The type description object must describe a non-generic type. Only type description objects for the generic ABAP types c, n, p, and x create a new bound data type and use it with the standard values. Similarly, a type description object for a standard table with a generic table type creates a new bound table type and uses it with a standard key.


Notes

The following are important methods for the dynamic definition of data types:

  • GET_C, GET_D, GET_F ... of the class CL_ABAP_ELEMDESCR for type description objects of elementary data types. These methods create either a new type description object in accordance with the input parameters or reuse an existing type object.
  • GET of the classes CL_ABAP_STRUCTDESCR, CL_ABAP_TABLEDESCR, and CL_ABAP_REFDESCR plus GET_BY_NAME of the class CL_ABAP_REFDESCR for type description objects of structures, internal tables, and reference variables. These methods return the type description object that was specified using the input parameters. A new type description object is created or an existing one is used again.
  • CREATE of the classes CL_ABAP_STRUCTDESCR, CL_ABAP_TABLEDESCR, and CL_ABAP_REFDESCR for creating type description objects for structures, internal tables, and reference variables. These methods return the type description object that was specified using the input parameters. A new type description object is always created.
  • It is advisable to use the GET methods instead of CREATE to avoid creating multiple type description objects for a single type.


Example

Creates an anonymous data object using a type description object for a dictionary structure provided by RTTI.

DATA dref TYPE REF TO data. 

DATA(type) = CAST cl_abap_datadescr( 
  cl_abap_typedescr=>describe_by_name( 'SCARR' ) ). 

CREATE DATA dref TYPE HANDLE type. 

Executable Example

Creating a Structure Using RTTC

Continue

Creating a Structure Using RTTC