Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

"Object requested is currently locked..." when executing BAPIs too fast

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

Former Member
Not what you were looking for? View more on this topic or Ask a question