<?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: Rollback after 3 inserts not working in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/rollback-after-3-inserts-not-working/m-p/12650741#M2015022</link>
    <description>&lt;P&gt;Thanks Jan. That's what I did.&lt;/P&gt;</description>
    <pubDate>Fri, 31 Mar 2023 10:55:15 GMT</pubDate>
    <dc:creator>ekekakos</dc:creator>
    <dc:date>2023-03-31T10:55:15Z</dc:date>
    <item>
      <title>Rollback after 3 inserts not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rollback-after-3-inserts-not-working/m-p/12650739#M2015020</link>
      <description>&lt;P&gt;Hello, I have the following problem. I am trying to update update several Z DB tables with the following code&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;INSERT zek_xk_lines FROM TABLE db_xk_lines ACCEPTING DUPLICATE KEYS.
IF sy-subrc = 0.
  INSERT zek_xklinkae FROM TABLE db_xk_line_kae ACCEPTING DUPLICATE KEYS.
  IF sy-subrc = 0.
    IF wa_xk_line-xk_traffic_ticket IS NOT INITIAL.
      db_xk_line_traffic = CORRESPONDING #( wa_xk_line-xk_traffic_ticket ).
      INSERT zek_xklinedt FROM TABLE db_xk_line_traffic ACCEPTING DUPLICATE KEYS.
      IF sy-subrc = 0.
        COMMIT WORK AND WAIT.
      ELSE.
        ROLLBACK WORK.
        r_result = |Failed to insert in DB TRAFFIC TICKETS (zek_xklinedt)|.
      ENDIF.
    ENDIF.
    IF wa_xk_line-xk_rent IS NOT INITIAL.
      db_xk_line_rents = CORRESPONDING #( wa_xk_line-xk_rent ).
      INSERT zek_xk_rent FROM TABLE db_xk_line_rents ACCEPTING DUPLICATE KEYS.
      IF sy-subrc = 0.
        COMMIT WORK AND WAIT.
      ELSE.
        ROLLBACK WORK.
        r_result = |Failed to insert in DB RENTS (zek_xk_rents)|.
      ENDIF.
    ENDIF.
    IF wa_xk_line-xk_doses IS NOT INITIAL.
      db_xk_line_doses = CORRESPONDING #( wa_xk_line-xk_doses ).
      INSERT zdae_migt_doses FROM TABLE db_xk_line_doses ACCEPTING DUPLICATE KEYS.
      IF sy-subrc = 0.
        COMMIT WORK AND WAIT.
      ELSE.
        ROLLBACK WORK.
        r_result = |Failed to insert in DB DOSES (zdae_migt_doses)|.
      ENDIF.
    ENDIF.
    IF r_result = ''.
      COMMIT WORK AND WAIT.
    ENDIF.
  ELSE.
    ROLLBACK WORK.
    r_result = |Failed to insert in DB KAE|.
  ENDIF.
ELSE.
  ROLLBACK WORK.
  r_result = |Failed to insert in DB LINE|.
ENDIF.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I noticed that when the INSERT of the 2nd table fails subrc=4 because of the duplicate keys, the ROLLBACK WORK is not working and Commits all the inserted records even for the 2nd one.&lt;/P&gt;
  &lt;P&gt;Does anyone knows why and what to do?&lt;/P&gt;
  &lt;P&gt;Thanks&lt;/P&gt;
  &lt;P&gt;Elias&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 08:55:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rollback-after-3-inserts-not-working/m-p/12650739#M2015020</guid>
      <dc:creator>ekekakos</dc:creator>
      <dc:date>2023-03-31T08:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Rollback after 3 inserts not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rollback-after-3-inserts-not-working/m-p/12650740#M2015021</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;ROLLBACK WORK does not revert changes in the database that were already committed - is this possibly your assumption? Once executed, a COMMIT WORK effects all updates in the database in the LUW done so far. BTW, if you do not use asynchronous updates you should not use the addition AND WAIT.&lt;/P&gt;&lt;P&gt;In the above given source code I would assume that a final COMMIT WORK resp. ROLLBACK WORK at the end would be more fitting to the needs.&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Jan&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 09:47:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rollback-after-3-inserts-not-working/m-p/12650740#M2015021</guid>
      <dc:creator>jmodaal</dc:creator>
      <dc:date>2023-03-31T09:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Rollback after 3 inserts not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rollback-after-3-inserts-not-working/m-p/12650741#M2015022</link>
      <description>&lt;P&gt;Thanks Jan. That's what I did.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 10:55:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rollback-after-3-inserts-not-working/m-p/12650741#M2015022</guid>
      <dc:creator>ekekakos</dc:creator>
      <dc:date>2023-03-31T10:55:15Z</dc:date>
    </item>
  </channel>
</rss>

