Ansicht
Dokumentation

ABENSHM_AREA_CONSTRUCTOR_CLASS - SHM AREA CONSTRUCTOR CLASS

ABENSHM_AREA_CONSTRUCTOR_CLASS - SHM AREA CONSTRUCTOR CLASS

ABAP Short Reference   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

- Area Constructor Class

An area constructor class is a global class with a freely selectable name that implements the interface IF_SHM_BUILD_INSTANCE. An area constructor can be implemented in the interface method BUILD.

An area constructor class can be assigned to an area in transaction SHMA. This is always necessary if the area is to be built automatically by calling the area constructor, that is, if the components BUILD_KIND and REFRESH_TIME of the structure PROPERTIES of the class CL_SHM_AREA are filled accordingly. If an area is not built automatically, an area constructor class can be specified for the explicit area constructor call using the method BUILD of the area class.

Structure of an Area Constructor

The following structure is recommended for the area constructor implemented in the interface method BUILD:

  1. First, the area constructor must use the method ATTACH_FOR_WRITE to create an area handle with a write lock for the area instance passed in the parameter INST_NAME. Since the automatically created area constructor cannot be used to ensure that the write lock can be set, all exceptions must be caught and forwarded to the caller of the constructor by raising the interface exception CX_SHM_BUILD_FAILED. The original exception should be passed to the parameter PREVIOUS of the constructor of CX_SHM_BUILD_FAILED.
  2. As with every creation of a new area instance version, a root object must also be defined in the area constructor using the method SET_ROOT.
  3. The area instance version can then be built, which means that objects are stored in the shared memory.
  4. The created area handle has to be released again using the method DETACH_COMMIT. If an exception is raised, it is usually a programming error and should not be handled in the area constructor.
  5. If the area constructor was called automatically, a database commit must be triggered when a transactional area is built.

In an area constructor, no statements can be used that exit the current internal session (such as SUBMIT, CALL TRANSACTION, CALL SCREEN, MESSAGE for message types W, P, E, and so on).

Example

The following implementation can be used as a template for personal implementations.

CLASS area_constructor IMPLEMENTATION.
  METHOD if_shm_build_instance~build.
    DATA:
      my_handle TYPE REF TO area,
      my_data   TYPE REF TO area_root_class,
      my_except TYPE REF TO cx_root.
    TRY.
        my_handle = cl_my_area=>attach_for_write( inst_name ).
      CATCH cx_shm_error INTO my_except.
        RAISE EXCEPTION TYPE cx_shm_build_failed
                        EXPORTING previous = my_except.
    ENDTRY.
    CREATE OBJECT my_data AREA HANDLE my_handle.
    my_handle->set_root( my_data ).
    ... " code to build the area instance
    my_handle->detach_commit( ).
    IF invocation_mode = cl_shm_area=>invocation_mode_auto_build.
      COMMIT CONNECTION default.
    ENDIF.
  ENDMETHOD.
ENDCLASS.






TXBHW - Original Tax Base Amount in Local Currency   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 4503 Date: 20240329 Time: 134117     sap01-206 ( 53 ms )