Show TOC

Shared Objects - ExampleLocate this document in the navigation structure

Use

Area MY_AREA is created in transaction SHMA with the area root class CL_MY_DATA.

After the creation of an area handle referenced by my_handle that is bound to an area instance version of the MY_AREA area with write authorization, an instance of the area root class CL_MY_DATA of the area is created, set as a root object, and a method is called there that imports the 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 a different program, the shared object can be accessed as follows, whereby a method is called that outputs the object's 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.