Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_TRANSACTION_COMMIT lock issue

Former Member
0 Likes
2,286

Hi,

I am using BAPI_SALESORDER_CHANGE to update a salesorder delivery date. After the call to the BAPI, if sy-subrc EQ 0, I am calling BAPI_TRANSACTION_COMMIT with 'WAIT' parameter = 'X'.

After this call to the BAPI, the same salesorder is updated by some other process. But I am getting intermittent error like this:

'Salesorder XXXXXXXXXX is locked by user XXXX'

My understanding was that since the 'WAIT' parameter was set in the BAPI_TRANSACTION_COMMIT, this error would not occur since the program is waiting for the commit to complete and locks should be released after the update process. So this error should not have occured.

Moreover, this is happening not for all cases, only some of them..

Any help in finding out why this is happening would be highly appreciated. Thanks.

Regards,

Arun.

4 REPLIES 4
Read only

Former Member
0 Likes
1,219

Hi,

BAPIs will never return exceptions. So there is no need to check subrc after calling a bapi. Instead, we need to check the return table exported by the BAPI. If it contains any error messages, call 'BAPI_TRANSACTION_ROLLBACK'; if not commit the data to DB by calling 'BAPI_TRANSACTION_COMMIT' by passing WAIT = 'X'.

Regarding your locking issue, before calling bapi for changing the sales order, use the below statement.

SET UPDATE TASK LOCAL.

This will post data without taking much time. Press F1 on the above statement and read SAP documentation.

Hope this helps you!!!

Regards,

Ganga

Read only

0 Likes
1,219

I think update task local will though increase performance but it will be at cost of your server resources as change

requests ar not written to VBLOG ,instead main memoryYour workpreocess will be exclusively used.

You use them only in batch mode.

Read only

Clemenss
Active Contributor
0 Likes
1,219

Hi Arun,

the program will not continue after BAPI_TRANSACTION_COMMIT with WAIT = 'X' until the update task has completed the saving of the changed order.

Please explain how you make sure that 'some other process' does not start before?

Update Task local will not be persistent solution.

I think the order change process takes place before the program continues after waiting for update task being completete and locks released.

Post some code lines, perhaps it is obvious.

Regards,

Clemens

Read only

Former Member
0 Likes
1,219

hi

try to call ur RFC as background task

or

do one thing

before try to change the existing sales order through BAPI

try uing ENQUEUE_READ_TABLE FM to check that particular record is being locked

if it is not lockeed proceed with ur bapi call

else

throw a message saying the record is being locked by some other user

cheers

s.janagar