ABAP Keyword Documentation → ABAP - Reference → Creating Objects and Values → Shared Objects → Shared Objects - Classes and Interfaces → Shared Objects - IF_SHM_BUILD_INSTANCE
Shared Objects - Area Constructor Class
An area constructor class is a global class with a freely selectable name, which implements the IF_SHM_BUILD_INSTANCE interface. An area constructor can be implemented in the BUILD interface method.
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, in other words if the BUILD_KIND and REFESH_TIME components of the PROPERTIES structure of class CL_SHM_AREA are filled accordingly. If an area is not to be built automatically, an area constructor class can be specified for the explicit area constructor call using the area class's BUILD method.
Other versions:
7.31 | 7.40 | 7.54
Structure of an Area Constructor
The following structure is recommended for the area constructor implemented in the BUILD interface method:
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", "I", "E", and so on).
Example
The following implementation can be used as a template for new implementations.
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
TRY.
my_handle->detach_commit( ).
CATCH cx_shm_error INTO my_except.
RAISE EXCEPTION TYPE cx_shm_build_failed
EXPORTING previous = my_except.
ENDTRY.
IF invocation_mode = cl_shm_area=>invocation_mode_auto_build.
CALL FUNCTION 'DB_COMMIT'.
ENDIF.
ENDMETHOD.
ENDCLASS.