<?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: Regarding Lock before BAPI in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687279#M30815</link>
    <description>&lt;P&gt;This BAPI creates a new batch based on an existing one, so I don't see why/how to lock the new batch that is not yet created.&lt;/P&gt;&lt;P&gt;Am I missing something ?&lt;/P&gt;</description>
    <pubDate>Fri, 19 Oct 2018 14:13:55 GMT</pubDate>
    <dc:creator>franois_henrotte</dc:creator>
    <dc:date>2018-10-19T14:13:55Z</dc:date>
    <item>
      <title>Regarding Lock before BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687278#M30814</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;I am using on FM: BAPI_BATCH_SAVE_REPLICA to change the order status from restricted to unrestricted. &lt;/P&gt;
  &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;I want to implement a lock before that and then unlock it afterwards. &lt;/P&gt;
  &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;How shall I do that?&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 13:21:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687278#M30814</guid>
      <dc:creator>former_member591635</dc:creator>
      <dc:date>2018-10-19T13:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Lock before BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687279#M30815</link>
      <description>&lt;P&gt;This BAPI creates a new batch based on an existing one, so I don't see why/how to lock the new batch that is not yet created.&lt;/P&gt;&lt;P&gt;Am I missing something ?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 14:13:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687279#M30815</guid>
      <dc:creator>franois_henrotte</dc:creator>
      <dc:date>2018-10-19T14:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Lock before BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687280#M30816</link>
      <description>&lt;P&gt;Hi Francois, thanks for replying. &lt;BR /&gt;&lt;BR /&gt;We are using the BAPI just to change the work order status from Restricted to Unrestricted. &lt;/P&gt;&lt;P&gt;This is the code:&lt;/P&gt;&lt;P&gt;IF ls_batchstatus-restricted EQ abap_true.&lt;BR /&gt;
&lt;BR /&gt;ls_batchstatus-restricted = ' '.&lt;BR /&gt;ls_batchstatusx-restricted = abap_true.&lt;BR /&gt;
&lt;BR /&gt;CALL FUNCTION 'BAPI_BATCH_SAVE_REPLICA'&lt;BR /&gt;EXPORTING&lt;BR /&gt;material = ps_outtab-matnr&lt;BR /&gt;batch = ps_outtab-charg&lt;BR /&gt;batchstatus = ls_batchstatus&lt;BR /&gt;batchstatusx = ls_batchstatusx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but the thing is, sometimes I'm getting the message as "BATCH XXX OF MATERIAL XXX IS ALREADY LOCKED BY &amp;lt;User Name&amp;gt;". and if I just press ENTER, it is getting accepted.&lt;BR /&gt;&lt;BR /&gt;So when that's why I thought this must be a lock issue. I tested with "Wait up to 5 seconds" and it's working fine but it's not good practice to write a code like this. Hence want to add locks before and after that FM call. &lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 14:28:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687280#M30816</guid>
      <dc:creator>former_member591635</dc:creator>
      <dc:date>2018-10-19T14:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Lock before BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687281#M30817</link>
      <description>&lt;P&gt;OK then you just have to use this FMto enqueue the batch (it gives error if already locked) :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;VB_ENQUEUE_BATCH&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 14:45:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687281#M30817</guid>
      <dc:creator>franois_henrotte</dc:creator>
      <dc:date>2018-10-19T14:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Lock before BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687282#M30818</link>
      <description>&lt;P&gt;Okay, so &lt;BR /&gt;&lt;BR /&gt;Fm - VB_ENQUEUE_BATCH&lt;/P&gt;&lt;P&gt;and then FM - BAPI_BATCH_SAVE_REPLICA' call.&lt;/P&gt;&lt;P&gt;later, FM - VB_DEQUEUE_BATCH&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this correct ?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 14:56:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687282#M30818</guid>
      <dc:creator>former_member591635</dc:creator>
      <dc:date>2018-10-19T14:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Lock before BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687283#M30819</link>
      <description>&lt;P&gt;Yes &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And don't forget to commit.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 15:12:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687283#M30819</guid>
      <dc:creator>franois_henrotte</dc:creator>
      <dc:date>2018-10-19T15:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Lock before BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687284#M30820</link>
      <description>&lt;P&gt;All right, thank you so mcuh.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 15:21:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687284#M30820</guid>
      <dc:creator>former_member591635</dc:creator>
      <dc:date>2018-10-19T15:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Lock before BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687285#M30821</link>
      <description>&lt;P&gt;Hey, got the same message still. &lt;/P&gt;&lt;P&gt;If I debug that FM, just for 10 sec(without changing anything) then no issues but if I execute directly then that message again.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 18:10:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687285#M30821</guid>
      <dc:creator>former_member591635</dc:creator>
      <dc:date>2018-10-19T18:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Lock before BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687286#M30822</link>
      <description>&lt;P&gt;Hey, got the same message still.&lt;/P&gt;&lt;P&gt;If I debug that FM, just for 10 sec(without changing anything) then no issues but if I execute directly then that message again.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 18:11:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687286#M30822</guid>
      <dc:creator>former_member591635</dc:creator>
      <dc:date>2018-10-19T18:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Lock before BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687287#M30823</link>
      <description>&lt;P&gt;Could you try to replace the call of VB_ENQUEUE_BATCH with a call of ENQUEUE_EMMCH1E (or ENQUEUE_EMMCHA) using the _WAIT parameter and/or wrap this request for lock in some do loop, which would be better than a wild WAIT UP TO n SECONDS. The COMMIT or ROLLBACK WORK (or BAPI_TRANSACTION_*) will remove the lock.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Question: &lt;/EM&gt;&lt;EM&gt;under what circumstances&lt;/EM&gt;&lt;I&gt; are you calling the BAPI, in some BAdI at save/end of a transaction, in this case did you consider calling the BAPI in BACKGROUND UNIT/TASKto insure execution after previous transaction changes commited to database and locks removed?&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 06:59:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687287#M30823</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2018-10-22T06:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Lock before BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687288#M30824</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If you think that the batch should be unlocked, you have still the possibility to call function DEQUEUE_ALL before you start your processing.&lt;/P&gt;&lt;P&gt;About the call of a BAPI in background task, it may be necessary if you call it in an update task (the commit would generate a dump) but it does not seem to be the case here. However you can also try to use SET UPDATE TASK LOCAL before you call the BAPI and do the commit.&lt;/P&gt;&lt;P&gt;BR &lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 15:13:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-lock-before-bapi/m-p/687288#M30824</guid>
      <dc:creator>franois_henrotte</dc:creator>
      <dc:date>2018-10-22T15:13:46Z</dc:date>
    </item>
  </channel>
</rss>

