06-10-2011 8:51 AM
Hi everyone,
I require some advice and help regarding a "Locking" problem that occurs when I execute a BAPI directly after commiting the work that another BAPI just did.
My code uses 3 BAPIs to do picking and outbound delivery with references to a Sales Order using .NET Connector 3, they are:
BAPI_SALESORDER_CHANGE - Updates the Sales Order so that the lines get updated with Batch information and creates additional lines if a line was picked against several batches
BAPI_OUTB_DELIVERY_CREATE_SLS - Creates an outbound delivery from the Sales Order
BAPI_OUTB_DELIVERY_CONFIRM_DEC - Does the Post Goods Issue so the amount of materials is decreased
After invoking each of these BAPIs I invoke BAPI_TRANSACTION_COMMIT with the WAIT-flag set to 'X' so that it should COMMIT and WAIT untill SAP has done the job, because I wanted to avoid any problems regarding locks.
Even though I'm setting the WAIT-flag, I still sometimes get a "Object requested is currently locked by..." error when I try to invoke the BAPI_OUTB_DELIVERY_CONFIRM_DEC.
Why? I am using the WAIT-flag, this problem should NOT occur, what am I missing? Is there some other BAPI that I can invoke to see if there are any locks? If I add a Thread.Sleep of a couple of seconds before invoking the last BAPI i don't get the error. But that's a stupid solution because it's a race of who finishes first.. my sleep or SAP's locks getting released
06-10-2011 9:16 AM
Hi Mikael,
Very strange that this is happening after using WAIT parameter. Have a look at the function module ENQUEUE_READ. But this gives all the lock entries for the user.
Also have a look at this sap note, although it does not directly relate to your issue. Not sure if you are handling multiple sale orders at a time.
Note 1024902 - BAPI call of BAPI_SALESORDER_CHANGE in a loop
Regards
Rajvansh
06-10-2011 10:39 AM
Hello Rajvansh,
I know, it is very frustrating that even though I am setting the WAIT flag I still get the error sometimes. I'll look into ENQUEUE_READ and see if I can't use that to determine how long I need to wait.
Where do I find and read Note 1024902?
06-10-2011 10:49 AM
Hi,
For the note you need to go to service.sap.com. But you will require a User ID for that. You can get it from your BASIS guys.
Regards
Rajvansh
06-10-2011 2:31 PM
I've started logging the locks that are active before I try to confirm the outbound delivery and here are some locks that SAP does not remove even though I have set the WAIT-flag:
EDIDC - ??
LIKP - Sales Document Delivery Header Data
VBAK - Sales Document Header Data
I was hoping to have some specific Locks to check against and not just if there are any locks active for a specified user at all... Any suggestions?