CREATE DATA - AREA HANDLE
CREATE DATA dref AREA HANDLE handle ...
handle expects an object reference variable whose static type is CL_ABAP_MEMORY_AREA or one of its subclasses
(area class). When the statement is executed,
handle must point to an
area handle and the area
handle must be associated with an area instance version with a change lock. A reference like this can be created in one of the following ways:
- By inheriting the return value of the methods ATTACH_FOR_WRITE or ATTACH_FOR_UPDATE of an area class created using transaction SHMA.
- By inheriting the return value of the method GET_HANDLE_BY_... of any area class.
By inheriting the return value of the method GET_IMODE_HANDLE of the predefined class CL_IMODE_AREA.
The latter is a reference to an area handle for the current
internal session and
CREATE DATA operates as if the addition
AREA HANDLE is not specified.
The creation of anonymous data objects as shared objects is subject to the following restrictions for data references in the shared objects memory: the storage of data references in closed area instance versions of the shared objects memory is restricted to those dynamic types that are known when loading a program into an internal session.
Therefore, the following data types cannot be used to create anonymous data objects in the shared object memory, if these are to be preserved in a closed area instance version:
GENERATE SUBROUTINE POOL.
Points 3 and 4 include the statement
CREATE DATA with the addition
AREA HANDLE itself. Exceptions to the restrictions listed under points 2 to 4 are:
The restrictions are not valid for data type
The restrictions are not valid for data types
xas long as the memory requirements do not exceed 100 bytes.
If a data reference variable that is stored in the shared objects memory refers to an anonymous data object of a dynamic type that is subject to the restrictions, the exception of the class CX_SHM_EXTERNAL_TYPE is raised when the DETACH_COMMIT method is executed.
The following can be used without restriction:
- All visible data types of global interfaces and classes.
- Data elements, structures, and database tables and table types from ABAP Dictionary.
- Data types from type groups.
Bound data types of anonymous data objects created at program runtime to which a static type with a static length was assigned when they were created using
Bound data types of anonymous data objects created at program runtime to which a fully specified dynamic type was assigned when they were created using
All data types that were created statically in the same program using declarative statements. It should
be noted, however, that it is no longer possible to access existing area instances once the creating program is changed.
TABLE OF can be used
as long as the specified types meet the above requirements. This also applies to the addition
HANDLE, which means the type description object must have been created with methods of the
RTTI from allowed types.
- The only shared object that can be addressed from an ABAP program directly after a binding is made to an area instance version is the instance of the area root class. All other objects have to be referenced in this instance. In particular, there is no direct access to anonymous data objects possible. Instead, the instance of the area root class must contain references to these anonymous data objects, which can also be indirect.
It is best to use only global data types with
AREA HANDLE. As an occasional replacement for the direct reference to data elements and table types from ABAP Dictionary, the respective types can be created in global interfaces, classes, or even type groups.
Creates an anonymous structure in an area instance version of area CL_DEMO_AREA.
DATA: root TYPE REF TO cl_demo_root, handle TYPE REF TO cl_demo_area. ... handle = cl_demo_area=>attach_for_write( ). CREATE OBJECT root AREA HANDLE handle. handle->set_root( root ). CREATE DATA root->dref AREA HANDLE handle TYPE scarr. ...
Cause: The area handle does not hold any change locks.
Cause: The area handle is not bound to an area instance version.
Cause: There is not enough memory.