背景
使用如下代码写入shared object
data:lo_root type ref to ycl_shared_object.
data(lo_shm_handle) = ypwk_area_emp=>attach_for_write( inst_name = 'YTEST' ).
create object lo_root area handle lo_shm_handle.
lo_shm_handle->set_root( lo_root ).
lo_root->set_data(
exporting
number = '548736'
name ='Wilbur new'
).
lo_shm_handle->detach_commit( ).
查看步骤
事务代码SHMM,找到相应的shared object并双击
选择一个实例,点击读取活动版本按钮
新打开的session如图所示,正是我们写入的数据
读取代码
shared object会持久存储在shared memory中,因此可以实现跨program或LUW的读取,代码如下
data(lo_shm_handle) = ypwk_area_emp=>attach_for_read( inst_name = 'YTEST' ).
lo_shm_handle->root->get_data(
importing
number = data(lv_number)
name = data(lv_name)
).
lo_shm_handle->detach( ).
write:lv_number, / lv_name.