Skip to content

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

CREATE OBJECT - AREA HANDLE

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


CREATE OBJECT oref AREA HANDLE handle ... 

Effect

This statement creates an object as a shared object in the area instance version of the shared memory, which is bound to the area handle referenced by handle. The implicitly or explicitly specified class must be defined as a shared-memory-enabled class using the addition SHARED MEMORY ENABLED of the statement CLASS.

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:

The latter is a reference to an area handle for the current internal session and the statement CREATE OBJECT operates as if the addition AREA HANDLE were not specified.


Notes

  • 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.
  • The static attributes of a shared object are not created in the shared memory. Instead, they are created when the shared-memory-enabled class is loaded to the internal session of a program, as for every class. They can thus occur more than once and independently of one another in different programs.

Example

Creation of a shared object in an area instance version of area CL_DEMO_AREA.

CLASS cls DEFINITION 
          SHARED MEMORY ENABLED. 
  ... 
ENDCLASS. 

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 OBJECT root->oref AREA HANDLE handle TYPE cls. 

... 

Executable Example

Creating an Instance of a Class as a Shared Object

Exceptions

Handleable Exceptions

CX_SHM_WRONG_HANDLE

  • Cause: The area handle does not hold any change locks.

CX_SHM_ALREADY_DETACHED

  • Cause: The area handle is not bound to an area instance version.

CX_SHM_OUT_OF_MEMORY

  • Cause: There is not enough memory.

CX_SHM_OBJECT_NOT_SERIALIZABLE

  • Cause: In an area instance displaceable using backup and recovery, an attempt was made to create an object that cannot be serialized.

Continue

Creating an Instance of a Class as a Shared Object