CREATE OBJECT - AREA HANDLE

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, to which the area handle referenced by handle is associated. The implicitly or explicitly specified class must be defined as a shared memory enabled class using the SHARED MEMORY ENABLED addition of the CLASS statement.

For handle you must specify 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 refer to an area handle and the area handle must be associated to an area instance version with a change lock. To create such a reference, you can do either of the following:

The latter is a reference to the area handle for the current internal session and the CREATE OBJECT statement has the effect it does without the AREA HANDLE addition.

Note

The only shared object that can be addressed directly from an ABAP program after a connection to an area instance version is the instance of the area root class. All other objects have to be referenced in this instance.

Example

After you have created an area handle referenced by my_handle, which is associated to an area instance version of the area my_area with write authorization, an instance of the area root class cl_my_data of the area is created and a method is then called which imports data into the object.

DATA: my_handle TYPE REF TO cl_my_area,
      my_data   TYPE REF TO cl_my_data.

TRY.
    my_handle = cl_my_area=>attach_for_write( ).

    CREATE OBJECT my_data AREA HANDLE my_handle.

    my_handle->set_root( my_data ).

    my_data->read_spfli( ).

    my_handle->detach_commit( ).

  CATCH cx_shm_attach_error.
    ...
ENDTRY.

In another program, you can access the shared object as follows. In this case, a method is called that outputs the object data.

DATA my_handle TYPE REF TO cl_my_area.

TRY.
    my_handle = cl_my_area=>attach_for_read( ).

    my_handle->root->output_spfli( ).

    my_handle->detach( ).

  CATCH cx_shm_attach_error.
    ...
ENDTRY.