<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Sharing Runtime objects to shared memory using SHMA in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sharing-runtime-objects-to-shared-memory-using-shma/m-p/12113751#M1973751</link>
    <description>&lt;P&gt;I have been working on shared memory objects, Used it many times to share flat structures.&lt;/P&gt;
  &lt;P&gt;This time I wanted to share objects(runtime) of a z-class using shared memory. &lt;/P&gt;
  &lt;P&gt;getting "The exception 'CX_SHM_EXTERNAL_REFERENCE' was raised, but it was not caught anywhere along" when detaching after "attach_for_write( ).".&lt;/P&gt;
  &lt;P&gt;Below is what I am trying to do.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;DATA lr_handle TYPE REF TO ZCL_TEST_SHARED_MEM_AREA. " Area Class

DATA lr_root TYPE REF TO ZCL_TEST_SHARED_MEM_ROOT. " Root attribute of handle class. SHM: Model of a Data Clas
******************************************************
* First Try to Read
data excp type ref to cx_shm_no_active_version.
data lf_readerror type c1.

try.
 lr_handle = ZCL_TEST_SHARED_MEM_AREA=&amp;gt;attach_for_read( ).
 lr_handle-&amp;gt;root-&amp;gt;get_object( IMPORTING e_grid = gv_docking ).
 lr_handle-&amp;gt;detach( ).
catch cx_shm_no_active_version into excp.
 lf_readerror = 'X'.
endtry.
******************************************************
IF lf_readerror = 'X'.
 lr_handle = ZCL_TEST_SHARED_MEM_AREA=&amp;gt;attach_for_write( ).
ELSE.
 lr_handle = ZCL_TEST_SHARED_MEM_AREA=&amp;gt;attach_for_update( ).
ENDIF.

CREATE OBJECT lr_root AREA HANDLE lr_handle.
lr_handle-&amp;gt;set_root( lr_root ).
CREATE OBJECT gv_docking.     " this may be any object of my intrest
lr_root-&amp;gt;set_object( EXPORTING p_grid = gv_docking ). " a mehtod in root class to save my object to SM
lr_handle-&amp;gt;detach_commit( ).&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Is it even possible to share class objects using shared memory.!&lt;/P&gt;</description>
    <pubDate>Wed, 13 Nov 2019 15:17:13 GMT</pubDate>
    <dc:creator>sriharsha_parayatham</dc:creator>
    <dc:date>2019-11-13T15:17:13Z</dc:date>
    <item>
      <title>Sharing Runtime objects to shared memory using SHMA</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sharing-runtime-objects-to-shared-memory-using-shma/m-p/12113751#M1973751</link>
      <description>&lt;P&gt;I have been working on shared memory objects, Used it many times to share flat structures.&lt;/P&gt;
  &lt;P&gt;This time I wanted to share objects(runtime) of a z-class using shared memory. &lt;/P&gt;
  &lt;P&gt;getting "The exception 'CX_SHM_EXTERNAL_REFERENCE' was raised, but it was not caught anywhere along" when detaching after "attach_for_write( ).".&lt;/P&gt;
  &lt;P&gt;Below is what I am trying to do.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;DATA lr_handle TYPE REF TO ZCL_TEST_SHARED_MEM_AREA. " Area Class

DATA lr_root TYPE REF TO ZCL_TEST_SHARED_MEM_ROOT. " Root attribute of handle class. SHM: Model of a Data Clas
******************************************************
* First Try to Read
data excp type ref to cx_shm_no_active_version.
data lf_readerror type c1.

try.
 lr_handle = ZCL_TEST_SHARED_MEM_AREA=&amp;gt;attach_for_read( ).
 lr_handle-&amp;gt;root-&amp;gt;get_object( IMPORTING e_grid = gv_docking ).
 lr_handle-&amp;gt;detach( ).
catch cx_shm_no_active_version into excp.
 lf_readerror = 'X'.
endtry.
******************************************************
IF lf_readerror = 'X'.
 lr_handle = ZCL_TEST_SHARED_MEM_AREA=&amp;gt;attach_for_write( ).
ELSE.
 lr_handle = ZCL_TEST_SHARED_MEM_AREA=&amp;gt;attach_for_update( ).
ENDIF.

CREATE OBJECT lr_root AREA HANDLE lr_handle.
lr_handle-&amp;gt;set_root( lr_root ).
CREATE OBJECT gv_docking.     " this may be any object of my intrest
lr_root-&amp;gt;set_object( EXPORTING p_grid = gv_docking ). " a mehtod in root class to save my object to SM
lr_handle-&amp;gt;detach_commit( ).&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Is it even possible to share class objects using shared memory.!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 15:17:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sharing-runtime-objects-to-shared-memory-using-shma/m-p/12113751#M1973751</guid>
      <dc:creator>sriharsha_parayatham</dc:creator>
      <dc:date>2019-11-13T15:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sharing Runtime objects to shared memory using SHMA</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sharing-runtime-objects-to-shared-memory-using-shma/m-p/12113752#M1973752</link>
      <description>&lt;P&gt;Unfortunately not possible, acc. to:&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.sap.com/questions/6058360/shared-objects-cxshmexternalreference-exception.html"&gt;Shared Objects "cx_shm_external_reference" exception&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.sap.com/questions/6058360/shared-objects-cxshmexternalreference-exception.html"&gt;&lt;/A&gt;&lt;A href="https://answers.sap.com/questions/1848162/cxshmexternalreference-exc-when-passing-class-inst.html"&gt;CX_SHM_EXTERNAL_REFERENCE exc. when passing Class instance to Shared memory&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 09:11:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sharing-runtime-objects-to-shared-memory-using-shma/m-p/12113752#M1973752</guid>
      <dc:creator>vaclav-pechek</dc:creator>
      <dc:date>2023-08-04T09:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Sharing Runtime objects to shared memory using SHMA</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sharing-runtime-objects-to-shared-memory-using-shma/m-p/12113753#M1973753</link>
      <description>&lt;P&gt;If the class is serializable/IF_SERIALIZABLE_OBJECT (that's very rare), you can serialize it into a String or Xstring and then you can share it.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 11:52:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sharing-runtime-objects-to-shared-memory-using-shma/m-p/12113753#M1973753</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-08-04T11:52:00Z</dc:date>
    </item>
  </channel>
</rss>

