<?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: Timing issue with commit and wait in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253670#M1986439</link>
    <description>&lt;P&gt;Did you check that fields from gw_rq001 are equal to wd_this-&amp;gt;bukrs werks tdrnr?&lt;BR /&gt;Or in other words are you sure you select the entry you updated?&lt;/P&gt;</description>
    <pubDate>Thu, 23 Mar 2023 12:25:15 GMT</pubDate>
    <dc:creator>harald_lesche-holzbecher</dc:creator>
    <dc:date>2023-03-23T12:25:15Z</dc:date>
    <item>
      <title>Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253660#M1986429</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
  &lt;P&gt;I updated my database table ZTD_RQ001 with new status = 03 and set to send email based on new status 03. However during the send email part, the retrieval from the table seems to be still previous status 02.&lt;/P&gt;
  &lt;P&gt;However...after checking the status in the DB table using SE16n the status is indeed 03.&lt;/P&gt;
  &lt;P&gt;Is there any time delay in from the time of my commit work and wait....commit work then select from ZTD_RQ001?&lt;/P&gt;
  &lt;P&gt;Is there anything wrong with my commit work and wait? I thought it supposed to update the status to 03 then only continue the codes below? Anyone have any idea?&lt;/P&gt;
  &lt;P&gt;I simplify the flow as shown in the code below.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;
gw_rq001-status ='03'.
MODIFY ztd_rq001 FROM gw_rq001.
    IF sy-subrc &amp;lt;&amp;gt; 0.
      re_error = 'X'. ROLLBACK WORK.
      lv_message = 'Error during update into the table'.
      wd_comp_controller-&amp;gt;message_manager-&amp;gt;report_error_message(
          message_text      = lv_message
          cancel_navigation = abap_true ).
      EXIT.
    ELSE.
      COMMIT WORK AND WAIT.
    ENDIF.

COMMIT WORK.
****send email part

****the ls_rq001-status from this point still seems to be 02
SELECT SINGLE * INTO ls_rq001
    FROM ztd_rq001
   WHERE bukrs = wd_this-&amp;gt;bukrs
     AND werks = wd_this-&amp;gt;werks
     AND tdrnr = wd_this-&amp;gt;tdrnr.
  IF sy-subrc &amp;lt;&amp;gt; 0.
    RETURN.
  ENDIF.
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Aug 2020 10:45:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253660#M1986429</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2020-08-25T10:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253661#M1986430</link>
      <description>&lt;P&gt;Dear Siong,&lt;/P&gt;&lt;P&gt;I assume that you have made a select to chose the data you want to modify, before the modify statement, right?&lt;/P&gt;&lt;P&gt;so before this : &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;gw_rq001-status ='03'.MODIFY ztd_rq001 FROM gw_rq001.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;you should have : &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT *INTO table gt_rq001
    FROM ztd_rq001
   WHERE bukrs = wd_this-&amp;gt;bukrs
     AND werks = wd_this-&amp;gt;werks
     AND tdrnr = wd_this-&amp;gt;tdrnr.
loop at gt_rq001 into gw_rq001.
*inside here your code
gw_rq001-status ='03'.
MODIFY ztd_rq001 FROM gw_rq001.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;let me know if it works.&lt;/P&gt;&lt;P&gt;Roxani&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 10:54:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253661#M1986430</guid>
      <dc:creator>former_member537489</dc:creator>
      <dc:date>2020-08-25T10:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253662#M1986431</link>
      <description>&lt;P&gt;Hi Roxani,&lt;/P&gt;&lt;P&gt;No. It is I update the table with status 03 first then only I select. I assume the table should be updated with 03 now. The problem here is the value is still 02 during the select time. This scenario does not happens everytime. &lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 11:12:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253662#M1986431</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2020-08-25T11:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253663#M1986432</link>
      <description>&lt;P&gt;Hi Check all primary key has been filled along with status.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 12:00:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253663#M1986432</guid>
      <dc:creator>ponrajasekharan</dc:creator>
      <dc:date>2020-08-25T12:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253664#M1986433</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;No need to write Commit 2 times,use the stmt like &lt;STRONG&gt;Commit work and Wait up to 3 seconds&lt;/STRONG&gt;.it will resolve your issue.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 12:01:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253664#M1986433</guid>
      <dc:creator>babu_gavi</dc:creator>
      <dc:date>2020-08-25T12:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253665#M1986434</link>
      <description>&lt;P&gt;There's no delay. COMMIT WORK AND WAIT is not needed (AND WAIT is not for the direct database update as yours, it's to be used only if you have used CALL FUNCTION 'XXX' IN UPDATE TASK).&lt;/P&gt;&lt;P&gt;There's an issue in your code somewhere. Are you sure of the origin of the "status" that you use for the email processing? Do you execute UPDATE/SELECT in different asynchronous threads?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 12:25:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253665#M1986434</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-08-25T12:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253666#M1986435</link>
      <description>&lt;P&gt;Hi Sandra,&lt;/P&gt;&lt;P&gt;As you can see above there is 2 commit statement before I re-select the ZTD_RQ001 table again assuming the status field will be updated with 03 value. But let say, if the SAP system is slow or there is network issue on the day...there seems to be the value is still not updated with 03 at the select part. &lt;/P&gt;&lt;P&gt;Is commit work and wait up to xx seconds is the only solution here? &lt;/P&gt;&lt;P&gt;1. I dont know how many seconds I need to put &lt;/P&gt;&lt;P&gt;2. It will make the system slow&lt;/P&gt;&lt;P&gt;Is this a solution left only?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 01:26:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253666#M1986435</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2020-08-26T01:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253667#M1986436</link>
      <description>&lt;P&gt;Is there parallel activities expected writing the content of the database table?&lt;BR /&gt;(From an update task to an asynchronous call to an external system with an RFC call back etc., or to another user?)&lt;/P&gt;&lt;P&gt;If not, a simple COMMIT WORK should be sufficient as all OpenSQL database requests are synchronous. COMMIT WORK AND WAIT is for the case when you need to wait for update processing, however I see no CALL FUNCTION IN UPDATE TASK in your code snippet.&lt;/P&gt;&lt;P&gt;If there are parallel activities, lock handling might be badly missing.&lt;/P&gt;&lt;P&gt;(There is a potential consistency issue with the change being committed even if there is an error sending the mail. I assume this is not the issue you are looking for.)&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 07:02:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253667#M1986436</guid>
      <dc:creator>gasparerdelyi</dc:creator>
      <dc:date>2020-08-26T07:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253668#M1986437</link>
      <description>&lt;P&gt;Could it be an issue if the DB Table is Buffered?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 10:07:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253668#M1986437</guid>
      <dc:creator>neil_nicholls</dc:creator>
      <dc:date>2023-03-23T10:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253669#M1986438</link>
      <description>&lt;P&gt;A tip - if you're leaving a program block, use RETURN rather than EXIT. EXIT behaves differently depending on context - RETURN always leaves the program block.&lt;/P&gt;&lt;P&gt;Anyway...&lt;/P&gt;&lt;P&gt;Can you not simply use the contents of gw_rq001 to generate the email? Why are you reading the same data back from the database?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 10:28:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253669#M1986438</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2023-03-23T10:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253670#M1986439</link>
      <description>&lt;P&gt;Did you check that fields from gw_rq001 are equal to wd_this-&amp;gt;bukrs werks tdrnr?&lt;BR /&gt;Or in other words are you sure you select the entry you updated?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 12:25:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253670#M1986439</guid>
      <dc:creator>harald_lesche-holzbecher</dc:creator>
      <dc:date>2023-03-23T12:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Timing issue with commit and wait</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253671#M1986440</link>
      <description>&lt;P&gt;Hi Siong,&lt;/P&gt;&lt;P&gt;Better to split the update &amp;amp; email program's rather than having it in same program. &lt;/P&gt;&lt;P&gt;This is due to update timing issues.&lt;/P&gt;&lt;P&gt;Try writing the email code in a separate include program.&lt;/P&gt;&lt;P&gt;If it still doesn't work write the email logic in a separate program and execute them sequentially.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 17:27:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/timing-issue-with-commit-and-wait/m-p/12253671#M1986440</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2023-03-23T17:27:29Z</dc:date>
    </item>
  </channel>
</rss>

