03-14-2007 12:15 PM
I tried to write ABAP code to access Shared Memory but there is an error message
when compiling.
attach_for_write is unknown.
Based on note 857904-Upgrade from Release 6.40 to 7.0.
I try to re-generate my class with program RSGENSHO but it still doesn't work.
Kindly advise how I should edit/adjust my code.
Thank you !
03-16-2007 8:29 AM
hi Erika,
The concept of shared memory is a little different....There are two classes which are involved viz
1) your shared memory class that is generated by the wizard
2) The root class which is required for you access anything the shared memory.
You need to first identify the root class.... and then use that to do any operations to the shared area.
Attaching a very simple program for the same
REPORT ZSHARED_MEM2.
DATA : area type REF TO zcl_shared_area,
root TYPE REF TO zcl_shared_root.
Get a Pointer to the Shared Area
area = zcl_shared_area=>attach_for_write( ).
Create an instance of our Root
CREATE OBJECT root AREA HANDLE area.
Set initial value for our Message
root->set_message( 'This is the initialization of the Shared Memory' ).
Set the root back into the Area
area->set_root( root ).
Commit and Detach
area->detach_commit( ).
Hope this is helpful for you......Please reward points if helpful
03-16-2007 9:58 AM
Thank you Mijesh.
I have tried so already but it doesn't work.
I understand that the problem is due to different version of Web AS.
Are you on version 6.40 or 7.00?
Due to the note, it seems that we need modification.
Currently, my code look like this. And I'm getting error that
The field "ATTACH_FOR_WRITE" is unknown, but there is a field with the similar name "ATTACH_MODE_WAIT".
===================================
REPORT ZWRITE_AREA_XX.
data:
hdl type ref to zcl_shm_area_xx,
root type ref to zcl_shm_area_root_xx.
hdl = zcl_shm_area_xx=>attach_for_write().
CREATE OBJECT root AREA HANDLE hdl.
root->string_attr = 'Hello!!'.
hdl->set_root( root ).
hdl->detach_commit().
===========================
Kindly advise.