<?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: Using COMMIT WORK in User Exit or in BADI in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310583#M1027585</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;Use of 'Commit work' or FM 'BAPI_TRANSACTION_COMMIT' is not at all allowed in standard SAP transactions User-exit or BADI as this can lead to multiple commit works in standard program (one added in user-exit and other is in standard program).&lt;/P&gt;&lt;P&gt;Having multiple commit work statements in standard programs, many times leads to inconsistencies in database update because program will try to insert/update data in database multiple times which will fail.&lt;/P&gt;&lt;P&gt;So its good to avoid the use of 'commit work'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sumit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Aug 2008 13:26:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-08-04T13:26:52Z</dc:date>
    <item>
      <title>Using COMMIT WORK in User Exit or in BADI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310580#M1027582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it allowed if I want to use COMMIT WORK in code written in the User Exit or BADI?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me in this topic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lokking for a lot of ur quick replies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Prasad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2008 08:45:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310580#M1027582</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-04T08:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using COMMIT WORK in User Exit or in BADI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310581#M1027583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Prasad,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You &lt;STRONG&gt;should not use&lt;/STRONG&gt; the COMMIT WORK inside the BADI or USER EXIT as it will lead to inconsistancies in data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note : Commit and Roll back shold be avoided ( &lt;EM&gt;You Might have to use the Commit Work in some cases as of ur need&lt;/EM&gt; )in User exit and BADIs Because while executing its not always sure that all the values needed for database updations are present or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose steps 1,2,3,4 have to be completed before the transaction completes its Logical Unit of Work and calls the internal Commit Work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you are adding some piece of code through a User exit between step 2 and 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use a commit work, All the data manipulated in Step 1 and 2 will be saved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;however if somehow step 3 gets failed.(Which means LUW brakes and there should not be any database commit)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Evrythng should ROLLBACK at that time,including the data in step 1 and 2.&lt;/P&gt;&lt;P&gt;But it will not happen, as you have already used a Commit Work inside ur exit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this clarifies ur doubt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Debasish.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2008 12:05:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310581#M1027583</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-04T12:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using COMMIT WORK in User Exit or in BADI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310582#M1027584</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;if you are not allowed to use COMMIT WORK in your user-exit, I recommend you to use the function module 'BAPI_TRANSACTION_COMMIT'.&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;Sander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2008 13:04:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310582#M1027584</guid>
      <dc:creator>former_member192854</dc:creator>
      <dc:date>2008-08-04T13:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using COMMIT WORK in User Exit or in BADI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310583#M1027585</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;Use of 'Commit work' or FM 'BAPI_TRANSACTION_COMMIT' is not at all allowed in standard SAP transactions User-exit or BADI as this can lead to multiple commit works in standard program (one added in user-exit and other is in standard program).&lt;/P&gt;&lt;P&gt;Having multiple commit work statements in standard programs, many times leads to inconsistencies in database update because program will try to insert/update data in database multiple times which will fail.&lt;/P&gt;&lt;P&gt;So its good to avoid the use of 'commit work'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sumit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2008 13:26:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310583#M1027585</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-04T13:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using COMMIT WORK in User Exit or in BADI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310584#M1027586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;if you are not allowed to use COMMIT WORK in your user-exit, I recommend &lt;/P&gt;&lt;P&gt;&amp;gt;you to use the function module 'BAPI_TRANSACTION_COMMIT'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is an incorrect thing to do!  The function BAPI_TRANSACTION_COMMIT is just a wrapper around the COMMIT WORK statement so that it can be called as part of a remote transaction via RFC.  This will have the exact same bad effects as already documented by others in this thread as calling COMMIT WORK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within your user-exit you have the option of:&lt;/P&gt;&lt;P&gt;- Doing DB update, but don't commit them and when the overall transaction is commited by the standard transaction then your updates will also be commited.  &lt;/P&gt;&lt;P&gt;- Putting your updates into an Update Task function module and calling this during the user-exit.  It won't actually be executed until the main transaction calls the COMMIT WORK and then at that time it will be executed in an update process along with the other standard update fucntions as part of the transaction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Key thing, don't call COMMIT WORK or call BAPI_TRANSACTION_COMMIT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now that I've said that, here is a scenario that I've had in the past.  During user-exit I need to do updates to custom tables or call APIs that do updates to the DB and I need them to be commited immediatly as a seaperate DB transaction from the main calling program (Note, this is a very specific requirment becuase there is no roll-back possible).  The way to accomplish this is to put the updates and your COMMIT WORK into a function module and mark the function module as RFC enabled (note, does not need to be Update enabled because this isn't an update task).  In the User-Exit call the new function with the addition "Starting New Task"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;CALL FUNCTION func STARTING NEW TASK task &lt;/P&gt;&lt;P&gt;&amp;gt;             [DESTINATION {dest|{IN GROUP {group|DEFAULT}}}] &lt;/P&gt;&lt;P&gt;&amp;gt;              parameter_list &lt;/P&gt;&lt;P&gt;&amp;gt;              [{PERFORMING subr}|{CALLING meth} ON END OF TASK]. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By doing this function call in a new task it is actaully making an RFC to another process on one of the application servers and will be handled as a seperate DB transaction from the main program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So final note on this one, don't call COMMIT WORK or call BAPI_TRANSACTION_COMMIT but if you have a specific need to create a seperate DB transaction you can use this method that I've described but remember that there is no way to roll back the changes of the seperate transaction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2008 22:17:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310584#M1027586</guid>
      <dc:creator>ian_maxwell2</dc:creator>
      <dc:date>2008-08-04T22:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using COMMIT WORK in User Exit or in BADI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310585#M1027587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for the replies. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually my requirement is also not to update immediately.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, problem I am facing is, what I want to update gets overwritten at the last COMMIT in the standard Program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to overcome that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, could u please suggest the solution for that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking for ur a lot of replies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Prasad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2008 06:27:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310585#M1027587</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-05T06:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using COMMIT WORK in User Exit or in BADI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310586#M1027588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Question solved&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Aug 2008 11:51:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310586#M1027588</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-12T11:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using COMMIT WORK in User Exit or in BADI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310587#M1027589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Prasad,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May I know how you solve your problem? I have the same problem as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dale&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 03:06:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310587#M1027589</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-09-25T03:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using COMMIT WORK in User Exit or in BADI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310588#M1027590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maxwell , &lt;/P&gt;&lt;P&gt;Thanks for you answer , it cleared me concept of commit in badi/user exit/enhancement .&lt;/P&gt;&lt;P&gt;can you please confirm my understanding ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my understanding :&lt;/P&gt;&lt;P&gt;Situation :&lt;/P&gt;&lt;P&gt;i have in badi :&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px; background-color: #ffffff;"&gt;Select * from ZCUSTOM into table ITAB.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt; Read Table ITAB into WA_ITAB with key&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;WA_ITAB - Delivered_Quantity = WA_ITAB - Delivered_Quantity + 5 . &lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Modify table ITAB from WA_ITAB.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;If NOT ITAB[] IS INITIAL.&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&amp;nbsp; MODIFY ZCUSTOM from ITAB.&amp;nbsp; "&lt;SPAN style="color: #333333; font-size: 12px;"&gt;"updatin the DB&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Commit work .&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;endif.&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;so as u told we should not use commit work inside , hence we need to use this piece of code inside a FM and call that FM as CALL 'XXX' in update task .&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;so after badi completes its transaction , a standard COMMIT WORK is triggered and after that COMMIT WORK is triggered our FM 'XXX' will be executed ?&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;is my understanding is write ?&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Awaiting for your response .&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;thanks,&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background: #ffffff;"&gt;Praveeen.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2015 17:43:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-commit-work-in-user-exit-or-in-badi/m-p/4310588#M1027590</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-10-09T17:43:36Z</dc:date>
    </item>
  </channel>
</rss>

