<?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 Re: internal table in shared memory in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116724#M1186791</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
myshmhandle = zca_shm_repstat_area=&amp;gt;attach_for_update( ).

CREATE OBJECT myroot AREA HANDLE myshmhandle.

read table myshmhandle-&amp;gt;root-&amp;gt;it_stat with key mandt = sy-mandt report = sy-repid
  ASSIGNING &amp;lt;p&amp;gt;.

 if sy-subrc = 0.
    &amp;lt;p&amp;gt;-freq    = wa_stat-freq + 1.
    &amp;lt;p&amp;gt;-ldate   = sy-datum.
    &amp;lt;p&amp;gt;-ltime   = sy-uzeit.
    &amp;lt;p&amp;gt;-userid  = sy-uname.

    ins = abap_false.
  else.
    wa_stat-mandt   = sy-mandt.
    wa_stat-report  = sy-repid.
    wa_stat-freq    = 1.
    wa_stat-ldate   = sy-datum.
    wa_stat-ltime   = sy-uzeit.
    wa_stat-userid  = sy-uname.

    ins = abap_true.
    append wa_stat to myroot-&amp;gt;it_stat.
  endif.

myshmhandle-&amp;gt;set_root( myroot ).
myshmhandle-&amp;gt;detach_commit( ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running the first time, everyting is ok. Running the second time the read will give back sy-subrc = 0 and &amp;lt;p&amp;gt; contains the correct values. after running to the end the table has no rows at all and is inconsitent &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt; I cant see what i'm doing wrong.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Feb 2009 20:13:40 GMT</pubDate>
    <dc:creator>rainer_hbenthal</dc:creator>
    <dc:date>2009-02-03T20:13:40Z</dc:date>
    <item>
      <title>internal table in shared memory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116718#M1186785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using an internal table in a shared memory area. Depending on the existance of rows i would like to modify these rows or appending new rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So i need read and write access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to use attach_for_write( ) but after that i cannot read the table, sy-subrc is always 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So i tried to read the table with attach_for_read( ) first. I can read it, and the result is now sy-subrc = 0. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But after attaching the table via attach_for_write i'm unable to modify the table, how can i do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 18:52:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116718#M1186785</guid>
      <dc:creator>rainer_hbenthal</dc:creator>
      <dc:date>2009-02-03T18:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: internal table in shared memory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116719#M1186786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;assign a field symbol to ur internal table and make changes to ur field symbol. the changes shud get reflected in ur internal table also.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 18:57:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116719#M1186786</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-03T18:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: internal table in shared memory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116720#M1186787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use method ATTACH_FOR_UPDATE to modify the data in the shared memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First Read it using the ATTACH_FOR_READ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now get the object by ATTACH_FOR_UPDATE&lt;/P&gt;&lt;P&gt;Call your Update method&lt;/P&gt;&lt;P&gt;Commit work by&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    my_handle-&amp;gt;detach_commit( ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 19:07:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116720#M1186787</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2009-02-03T19:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: internal table in shared memory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116721#M1186788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is the modify statement itself, using modify the report abends because the modify statement does not have a binding to that table anymore.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fieldsymbols do not work, they are modifying the table directly which will not work if i'm in the read phase.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 19:26:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116721#M1186788</guid>
      <dc:creator>rainer_hbenthal</dc:creator>
      <dc:date>2009-02-03T19:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: internal table in shared memory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116722#M1186789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you try to modify after the DETACH? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am able to modify my shared memory data using this code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TRY.
    my_handle = ztest_np=&amp;gt;attach_for_update( ).

    CREATE OBJECT my_data AREA HANDLE my_handle.

    my_handle-&amp;gt;set_root( my_data ).

*.. data modification logic begin
    CLEAR: my_data-&amp;gt;t_data.

    SELECT vbeln
           FROM  vbap
           INTO  CORRESPONDING FIELDS OF TABLE my_data-&amp;gt;t_data
           UP TO 25 ROWS.

*.. data modification logic end
    my_handle-&amp;gt;detach_commit( ).

  CATCH cx_shm_attach_error.
    ...
ENDTRY.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 19:34:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116722#M1186789</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2009-02-03T19:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: internal table in shared memory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116723#M1186790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To simplify, just use ROOT attribute :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TRY.
    my_handle = ztest_np=&amp;gt;attach_for_update( ).
 
*.. data modification logic begin
    CLEAR: my_handle-&amp;gt;root-&amp;gt;t_data.
 
    SELECT vbeln
           FROM  vbap
           INTO  CORRESPONDING FIELDS OF TABLE my_handle-&amp;gt;root-&amp;gt;t_data.
           UP TO 25 ROWS.
 
*.. data modification logic end
    my_handle-&amp;gt;detach_commit( ).
 
  CATCH cx_shm_attach_error.
    ...
ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 19:45:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116723#M1186790</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2009-02-03T19:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: internal table in shared memory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116724#M1186791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
myshmhandle = zca_shm_repstat_area=&amp;gt;attach_for_update( ).

CREATE OBJECT myroot AREA HANDLE myshmhandle.

read table myshmhandle-&amp;gt;root-&amp;gt;it_stat with key mandt = sy-mandt report = sy-repid
  ASSIGNING &amp;lt;p&amp;gt;.

 if sy-subrc = 0.
    &amp;lt;p&amp;gt;-freq    = wa_stat-freq + 1.
    &amp;lt;p&amp;gt;-ldate   = sy-datum.
    &amp;lt;p&amp;gt;-ltime   = sy-uzeit.
    &amp;lt;p&amp;gt;-userid  = sy-uname.

    ins = abap_false.
  else.
    wa_stat-mandt   = sy-mandt.
    wa_stat-report  = sy-repid.
    wa_stat-freq    = 1.
    wa_stat-ldate   = sy-datum.
    wa_stat-ltime   = sy-uzeit.
    wa_stat-userid  = sy-uname.

    ins = abap_true.
    append wa_stat to myroot-&amp;gt;it_stat.
  endif.

myshmhandle-&amp;gt;set_root( myroot ).
myshmhandle-&amp;gt;detach_commit( ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running the first time, everyting is ok. Running the second time the read will give back sy-subrc = 0 and &amp;lt;p&amp;gt; contains the correct values. after running to the end the table has no rows at all and is inconsitent &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt; I cant see what i'm doing wrong.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 20:13:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116724#M1186791</guid>
      <dc:creator>rainer_hbenthal</dc:creator>
      <dc:date>2009-02-03T20:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: internal table in shared memory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116725#M1186792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this should work with these corrections :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;myshmhandle = zca_shm_repstat_area=&amp;gt;attach_for_update( ).
 
* CREATE OBJECT myroot AREA HANDLE myshmhandle. "DELETE
 
read table myshmhandle-&amp;gt;root-&amp;gt;it_stat with key mandt = sy-mandt report = sy-repid
  ASSIGNING &amp;lt;p&amp;gt;.
 
 if sy-subrc = 0.
    &amp;lt;p&amp;gt;-freq    = wa_stat-freq + 1.
    &amp;lt;p&amp;gt;-ldate   = sy-datum.
    &amp;lt;p&amp;gt;-ltime   = sy-uzeit.
    &amp;lt;p&amp;gt;-userid  = sy-uname.
 
    ins = abap_false.
  else.
    wa_stat-mandt   = sy-mandt.
    wa_stat-report  = sy-repid.
    wa_stat-freq    = 1.
    wa_stat-ldate   = sy-datum.
    wa_stat-ltime   = sy-uzeit.
    wa_stat-userid  = sy-uname.
 
    ins = abap_true.
*    append wa_stat to myroot-&amp;gt;it_stat. "DELETE
    append wa_stat to myshmhandle-&amp;gt;root-&amp;gt;it_stat. "ADD
  endif.

* myshmhandle-&amp;gt;set_root( myroot ). "DELETE
myshmhandle-&amp;gt;detach_commit( ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 22:01:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-in-shared-memory/m-p/5116725#M1186792</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2009-02-03T22:01:20Z</dc:date>
    </item>
  </channel>
</rss>

