<?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: How to prevent two DB update inconsistent issue? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680159#M30232</link>
    <description>&lt;P&gt;And each and every program that update those tables must use the same enqueue mechanism of course. &lt;/P&gt;</description>
    <pubDate>Tue, 17 Jul 2018 07:20:25 GMT</pubDate>
    <dc:creator>RaymondGiuseppi</dc:creator>
    <dc:date>2018-07-17T07:20:25Z</dc:date>
    <item>
      <title>How to prevent two DB update inconsistent issue?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680152#M30225</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; is there a possibility to prevent two DB update inconsistent? &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; I'm working on a program that want to update two add-on tables at the same time, but sometimes only header table (zheader) commit successfully, item table (zitem) not been update but without any exception. &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Is any issue for below code?　or I need to use in "update task update" for below update?&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;MODIFY zheader FROM TABLE it_zheader.
IF sy-subrc = 0. 
  l_flag = 'X'.
ELSE.
  l_flag = ''.
ENDIF.


MODIFY zitem FROM TABLE it_zitem.
IF sy-subrc = 0 AND l_flag = 'X'.
  l_flag = 'X'.
ELSE.
  l_flag = ''.
ENDIF.

IF l_flag = 'X'.
   COMMIT WORK AND WAIT.
ELSE.
  ROLLBACK WORK.
  MESSAGE s398 DISPLAY LIKE 'I' WITH 'Update table Successfully!'.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Thank you. &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Regards, &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Nicole&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 02:41:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680152#M30225</guid>
      <dc:creator>former_member587838</dc:creator>
      <dc:date>2018-07-16T02:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent two DB update inconsistent issue?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680153#M30226</link>
      <description>&lt;P&gt;Please in future use the "code" button in the editor when posting code. I've done it for you this time.&lt;/P&gt;
  &lt;P&gt;Your coding is poor. First of all, &lt;STRONG&gt;l_flag&lt;/STRONG&gt; is not a meaningful name for a variable. How about &lt;STRONG&gt;previous_modify_successful&lt;/STRONG&gt;, and use the provided &lt;STRONG&gt;abap_true&lt;/STRONG&gt; and &lt;STRONG&gt;abap_false&lt;/STRONG&gt; instead of arbitrary '' and 'X'. But the structure is also not good. as you attempt an update of zitem even when the zheader update has already failed.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;MODIFY zheader FROM TABLE it_zheader.
IF sy-subrc = 0.  
  MODIFY zitem FROM TABLE it_zitem.
  IF sy-subrc = 0 
    COMMIT WORK AND WAIT.
    db_modify_was_successful = abap_true.
  ENDIF.
ENDIF.
If db_modify_was_successful = abap_false.
  ROLLBACK WORK.
  MESSAGE s398 DISPLAY LIKE 'I' WITH 'Update table Successfully!'.
ENDIF&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Do you know &lt;STRONG&gt;it_item&lt;/STRONG&gt; isn't empty? Can you reproduce your observed issue? Have you tried debugging?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 05:02:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680153#M30226</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2018-07-16T05:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent two DB update inconsistent issue?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680154#M30227</link>
      <description>&lt;P&gt;Dear Mattehew,&lt;BR /&gt;Thanks for your good comments. actually the structure in our production is not like this (this is just a sample), we have the logic in previously form to check it_item empty or not, and this program already run for some time in production environment. don't know why some times item table update failed (we had traced item structure not empty at that moment, no any exception or DB lock occurred).&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 06:12:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680154#M30227</guid>
      <dc:creator>former_member587838</dc:creator>
      <dc:date>2018-07-16T06:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent two DB update inconsistent issue?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680155#M30228</link>
      <description>&lt;UL&gt;
   &lt;LI&gt;Please move the success message in the successful IF case...&lt;/LI&gt;
   &lt;LI&gt;As MODIFY would, by conception, not raise an error for duplicate primary keys, you should look for secondary unique indexes and locked records (at database level , what did you code to prevent this case) or even in system or database log.&lt;/LI&gt;
  &lt;/UL&gt;</description>
      <pubDate>Mon, 16 Jul 2018 07:05:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680155#M30228</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2018-07-16T07:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent two DB update inconsistent issue?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680156#M30229</link>
      <description>&lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;//Correct my code due my typo for message control as below, and highlight that I just need to update the exist record's status in these two tables, not insert new record, tks. 

MODIFY zheader FROM TABLE it_zheader.
IF sy-subrc = 0. 
  l_flag = 'X'.
ELSE.
  l_flag = ''.
ENDIF.

MODIFY zitem FROM TABLE it_zitem.
IF sy-subrc = 0 AND l_flag = 'X'.
  l_flag = 'X'.
ELSE.
  l_flag = ''.
ENDIF.

IF l_flag = 'X'.
   COMMIT WORK AND WAIT.
ELSE.
  ROLLBACK WORK.
  MESSAGE s398 DISPLAY LIKE 'I' WITH 'Update table Error!'.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jul 2018 01:34:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680156#M30229</guid>
      <dc:creator>former_member587838</dc:creator>
      <dc:date>2018-07-17T01:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent two DB update inconsistent issue?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680157#M30230</link>
      <description>&lt;P&gt;I just want to update some field's value for exist record's in these two tables, and I also can make sure that just no one update the same record at the same time, do I still need to lock the records? &lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 01:39:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680157#M30230</guid>
      <dc:creator>former_member587838</dc:creator>
      <dc:date>2018-07-17T01:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent two DB update inconsistent issue?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680158#M30231</link>
      <description>&lt;P&gt;You must use the SAP locking mechanism if there's a chance of concurrent update.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 07:09:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680158#M30231</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2018-07-17T07:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent two DB update inconsistent issue?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680159#M30232</link>
      <description>&lt;P&gt;And each and every program that update those tables must use the same enqueue mechanism of course. &lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 07:20:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680159#M30232</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2018-07-17T07:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent two DB update inconsistent issue?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680160#M30233</link>
      <description>&lt;P&gt;You mean use ENQUEUE and DEQUEUE lock mechanism to lock these two table? or any other? &lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 02:01:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680160#M30233</guid>
      <dc:creator>former_member587838</dc:creator>
      <dc:date>2018-07-18T02:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent two DB update inconsistent issue?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680161#M30234</link>
      <description>&lt;UL&gt; 
   &lt;LI&gt;Yes every program that update this table should use the same enqueue (e.g. E_TABLE)&lt;/LI&gt; 
   &lt;LI&gt;The COMMIT/ROLLBACK WORK will remove the lock, so no explicit call of DEQUEUE should be required.&lt;/LI&gt; 
  &lt;/UL&gt;</description>
      <pubDate>Wed, 18 Jul 2018 06:42:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-prevent-two-db-update-inconsistent-issue/m-p/680161#M30234</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2018-07-18T06:42:02Z</dc:date>
    </item>
  </channel>
</rss>

