Shared Memory Object Program

Sun Jul 10, 2022

SHARED MEMORY OBJECT - RECOMMEDED WAY OF TRANSFERRING THE DATA

Check out this Video for Detail understanding


"1st Program

*&---------------------------------------------------------------------*
*& Report ZSHMA_REPORT_EXPORT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
report zshma_report_export.

"Build the memory

try.

zcl_shma_demo_ic_area=>build( ).
catch cx_shma_not_configured. " SHM Administration: Area Property Is Not Configured

catch cx_shma_inconsistent. " SHM Administration: Inconsistent Attribute Combination

catch cx_shm_build_failed. " Constructor Run Failed


endtry.

try.
data(lr_area) = zcl_shma_demo_ic_area=>attach_for_update(
* inst_name = cl_shm_area=>default_instance
* attach_mode = cl_shm_area=>attach_mode_default
* wait_time = 0
).
catch cx_shm_inconsistent. " Different Definitions Between Program and Area

catch cx_shm_no_active_version. " No active version exists for an attach

catch cx_shm_exclusive_lock_active. " Instance Already Locked

catch cx_shm_version_limit_exceeded. " No Additional Versions Available

catch cx_shm_change_lock_active. " A write lock is already active

catch cx_shm_parameter_error. " Passed parameter has incorrect value

catch cx_shm_pending_lock_removed. " Shared Objects: Waiting Lock Was Deleted

endtry.

data: lr_root type ref to zcl_shma_demo_ic_root.

try.
lr_root ?= lr_area->get_root( ).
catch cx_shm_already_detached. " Handle Already Released

endtry.

lr_root->gv_value = 10.

SELECT EBELN ,EBELP, AEDAT FROM EKPO INTO TABLE @DATA(IT_PO).

LR_ROOT->gt_it = IT_PO.

lr_area->set_root( LR_ROOT ).

LR_AREA->detach_commit( ).

"2nd Program

*&---------------------------------------------------------------------*
*& Report ZSHMA_REPORT_IMPORT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
report zshma_report_import.

try.

data(lr_area) = zcl_shma_demo_ic_area=>attach_for_read( ).

catch cx_shm_inconsistent. " Differing Definitions Between Program and Area

catch cx_shm_no_active_version. " No active version exists for an attach

catch cx_shm_read_lock_active. " Request for a Second Read Lock

catch cx_shm_exclusive_lock_active. " Instance Already Locked

catch cx_shm_parameter_error. " Incorrect parameter passed
catch cx_shm_change_lock_active. " A Change Lock Is Already Active

endtry.

data: lr_root type ref to zcl_shma_demo_ic_root.

try.
lr_root ?= lr_area->get_root( ).
catch cx_shm_already_detached. " Handle Already Released
ENDTRY.

cl_demo_output=>display_data(
exporting
value = lr_root->gt_it
name = | { lr_root->gv_value } | " Name
).

Pankaj Kumar

Launch your GraphyLaunch your Graphy
100K+ creators trust Graphy to teach online
𝕏
SAP TECH MADE EASY 2024 Privacy policy Terms of use Contact us Refund policy