<?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: Usage of COMMIT WORK AND WAIT in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/usage-of-commit-work-and-wait/m-p/8296118#M1635229</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Martin;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do NOT put the COMMIT WORK AND WAIT in any kind of loop.  What you want to do is process all of your data, THEN call it.  Given the program I have, it works on multiple things and puts into an internal table all the keys to what it updates ( in particular, it's updating MARA - so it has MATNR in it.  I didn't include the declarations of wa and it_updated_list, assume that for this example all it has is one field called MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So here's what I did in a bit more detail in my program - yes I simplified it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT matnr&lt;/P&gt;&lt;P&gt;   INTO wa-matnr&lt;/P&gt;&lt;P&gt;   FROM mara&lt;/P&gt;&lt;P&gt;   WHERE ( some kind of condition ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  " Do a whole bunch of updates on stuff that relates to materials - code not included here&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  " Now save this material to be handled later on after the commit and wait&lt;/P&gt;&lt;P&gt;  append wa to it_updated_list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COMMIT WORK AND WAIT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;" Now I can do more things after my commit and wait&lt;/P&gt;&lt;P&gt;LOOP AT it_updated_list INTO wa&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  " do whatever you need to do here after the commit is done&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you were to call the COMMIT WORK AND WAIT in the SELECT loop, it would bomb on a runtime error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Sep 2011 16:17:02 GMT</pubDate>
    <dc:creator>bruce_hartley</dc:creator>
    <dc:date>2011-09-26T16:17:02Z</dc:date>
    <item>
      <title>Usage of COMMIT WORK AND WAIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/usage-of-commit-work-and-wait/m-p/8296114#M1635225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have one problem: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i am archiving a document with function module  'ARCHIV_CREATE_SYNCHRON_META'. &lt;/P&gt;&lt;P&gt;this function works fine but does not give back the unique archiv_id (no import parameter there)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so in the same abap i want to read the table where the above function module has stored the information&lt;/P&gt;&lt;P&gt;about the archiv_id&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so far so good, BUT: how can i ensure that the function module already has written into the database ? what if i can't fetch the row because it is not in the database ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can i use a COMMIT WORK AND WAIT here before i do a select on the table ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best regards, Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2011 14:46:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/usage-of-commit-work-and-wait/m-p/8296114#M1635225</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-26T14:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of COMMIT WORK AND WAIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/usage-of-commit-work-and-wait/m-p/8296115#M1635226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Martin;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some experience with COMMIT WORK AND WAIT, I'm pretty sure that what you described is what you are going to have to do.  I had to do something similar when I called a function module that was storing some things in the database and I had to make sure that they were there before continuting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just make sure that you don't put it inside a SELECT loop - I would strongly recommend that you break the program apart in such a way that nothing else is going on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I did in a program that had to retrieve what work I did was to break it up into 3 parts:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 - Read and updates as needed&lt;/P&gt;&lt;P&gt;2 - COMMIT WORK AND WAIT&lt;/P&gt;&lt;P&gt;3 - More work that depended on parts 1 and 2 being done&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2011 15:07:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/usage-of-commit-work-and-wait/m-p/8296115#M1635226</guid>
      <dc:creator>bruce_hartley</dc:creator>
      <dc:date>2011-09-26T15:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of COMMIT WORK AND WAIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/usage-of-commit-work-and-wait/m-p/8296116#M1635227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you ! well, i have to do the select in 2 loop....endloop. is THIS a problem too when i do a COMMIT WORK AND WAIT in a loop...endloop ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2011 15:12:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/usage-of-commit-work-and-wait/m-p/8296116#M1635227</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-26T15:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of COMMIT WORK AND WAIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/usage-of-commit-work-and-wait/m-p/8296117#M1635228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can only place the commit after calling the fm ARCHIV_CREATE_SYNCHRON_META, because this fm should update the table with doc id (I suppose TOA01 or something like that)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but probably you don't need it, you need to considere your all program is a single LUW, so all database modifications should be available in the LUW (few days ago this argument was discussed in a post), I mean:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES: &amp;lt;my table&amp;gt;.

&amp;lt;my table&amp;gt;-field_key = 'A'.
INSERT &amp;lt;my_table&amp;gt;.

SELECT SINGLE * 
  FROM &amp;lt;my table&amp;gt;-field_key = 'A'
WRITE SY-SUBRC.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you try to run this simple code you can note the SY-SUBRC is equal to 0, and there's no COMMIT after INSERT command,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is as the system gets data from rollback area where the modifications are stored at the moment,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it the fm ARCHIV_CREATE_SYNCHRON_META doesn't use the COMMIT, probably you can read its modification&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2011 15:46:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/usage-of-commit-work-and-wait/m-p/8296117#M1635228</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-26T15:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of COMMIT WORK AND WAIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/usage-of-commit-work-and-wait/m-p/8296118#M1635229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Martin;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do NOT put the COMMIT WORK AND WAIT in any kind of loop.  What you want to do is process all of your data, THEN call it.  Given the program I have, it works on multiple things and puts into an internal table all the keys to what it updates ( in particular, it's updating MARA - so it has MATNR in it.  I didn't include the declarations of wa and it_updated_list, assume that for this example all it has is one field called MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So here's what I did in a bit more detail in my program - yes I simplified it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT matnr&lt;/P&gt;&lt;P&gt;   INTO wa-matnr&lt;/P&gt;&lt;P&gt;   FROM mara&lt;/P&gt;&lt;P&gt;   WHERE ( some kind of condition ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  " Do a whole bunch of updates on stuff that relates to materials - code not included here&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  " Now save this material to be handled later on after the commit and wait&lt;/P&gt;&lt;P&gt;  append wa to it_updated_list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COMMIT WORK AND WAIT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;" Now I can do more things after my commit and wait&lt;/P&gt;&lt;P&gt;LOOP AT it_updated_list INTO wa&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  " do whatever you need to do here after the commit is done&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you were to call the COMMIT WORK AND WAIT in the SELECT loop, it would bomb on a runtime error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2011 16:17:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/usage-of-commit-work-and-wait/m-p/8296118#M1635229</guid>
      <dc:creator>bruce_hartley</dc:creator>
      <dc:date>2011-09-26T16:17:02Z</dc:date>
    </item>
  </channel>
</rss>

