‎2012 Mar 14 6:48 AM
Hi,
I am using the 'BAPI_GOODSMVT_CREATE' in a program to create GR for the production orders. The user would actually execute the program, go back and execute the program again to do the GR for the same order. This may be done in several iterations. The problem is that we are getting an error message 'Order locked by user XXXXX' after the first iteration. Because of this the GR doesn't happen properly for the orders.
Please let me if know how this lock error could be removed. I have used 'WAIT = X' parameter and WAIT UPTO 4 SECONDS and have used 'DEQUEUE_ESORDER' BAPI call also to remove the locks.
PS: The BAPI call is not inside a loop.
Thanks,
Pranil
‎2012 Mar 14 7:11 AM
Hi Pranil,
After successful BAPI Commit, Please use the FM CO_RU_DEQUEUE_ALL or CO_RU_ORDER_DEQUEUE to remove lock enforced on the Production order.
Hope this would help you. Thanks
Regards
Balaji R
‎2012 Mar 15 3:35 AM
Hi Balaji,
The problem persists even after using the FMs suggested by you.
Thanks,
Pranil
‎2012 Mar 14 7:40 AM
You must De queue after commit.
Here is the ref Code
* Call goods movement BAPI
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gm_header
goodsmvt_code = gm_code
importing
goodsmvt_headret = gm_headret
materialdocument = gm_retmtd
tables
goodsmvt_item = gm_item
return = gm_return.
if not gm_retmtd is initial.
<b> commit work and wait.
call function 'DEQUEUE_ALL'.</b>
write:/ gm_retmtd.
else.
commit work and wait.
call function 'DEQUEUE_ALL'.
endif.
‎2012 Mar 14 8:10 AM
When the transaction end's the lock gets released. Try coming out of the program session then again try executing it.
Thanks to Suhas for sharing this point.
‎2012 Mar 15 3:39 AM
It actually works if each execution is done in a new session. But the problem is that the user wouldn't go to the transaction (which was created for the program) or go to a new session each time for the execution.
Thanks,
Pranil
‎2012 Mar 15 12:44 PM
Hi,
Try CALL FUNCTION 'BAPI_GOODSMVT_CREATE' IN BACKGROUND TASK AS SEPARATE UNIT.
Regards,
Felipe