06-10-2014 6:02 PM
hi all,
My requirement is to post another transaction using BAPI_GOODSMVT_CREATE at MIGO in the background.
let say after posting movement type 101..i have to post another transaction of same material in same plant and in same Batch Using BADI,
The problem is, material and batch name were currently lock by movement type 101, So BAPI giving Error that Batch BHEL001 of material 1000000000004 is already locked by user01. i.e. from my ID.
Is it possible to remove this lock object?
These are the lock objects at SM12.
E MCH1 11000000100000000000400000XXXXX 0 1
E MCH1 11000000100000000000470206XXXXX 0 1
I tried
CALL FUNCTION 'DEQUEUE_EMMCH1E'
'DEQUEUE_all'
i don’t want to consider the wait options..
My problem is to remove lock objects in order to transact another movement type
thanks for your responce..
Pankaj
06-10-2014 6:12 PM
Hey,
I can think of something like this..
*Read all the lock details in system
CALL FUNCTION 'ENQUE_READ2'
EXPORTING
gclient = sy-mandt
gname = ' '
guname = '*'
TABLES
enq = lt_enq_read.
*We will search entry for table level lock for our table
LOOP AT lt_enq_read INTO lw_enq_read
WHERE gname EQ 'RSTABLE'
AND garg CS 'ZTEST_SHUKS3'.
MOVE-CORRESPONDING lw_enq_read TO lw_enq_del.
APPEND lw_enq_del TO lt_enq_del.
ENDLOOP.
*Delete table level lock entry for our table
CALL FUNCTION 'ENQUE_DELETE'
EXPORTING
check_upd_requests = 1
IMPORTING
subrc = lv_subrc
TABLES
enq = lt_enq_del.
You should first search for lock and manually delete them using above FM.
Hope it helps
Thanks,
Nitin
06-10-2014 7:37 PM
Pankaj,
More options ---
Can you call the BAPI in background task as separate unit? I guess by the time new function is called all locks are removed.
Also, I think BAPI internally uses FM: MB_CREATE_GOODS_MOVEMENT to post the goods movement. If you can build a custom Function Module to wrap MB_CREATE_GOODS_MOVEMENT and call the custom FM in background and as separate unit. I think this should resolve the locking and LUW issues you may have.
Please check SAP help for Call function <function_name> in background task
as separate unit.
Hope this helps,
Thanks,
VM.
06-10-2014 7:52 PM
This is not possible because the FM MB_CREATE_GOODS_MOVEMENT cannnot be called twice in the same session without calling BAPI_TRANSACTION_COMMIT after the first call.
06-10-2014 8:32 PM
I think "as separate unit" should take care of the same session issue.
In the Custom function module which is called in Background and as separate unit, can you add a wait statement for 5 seconds and then call 2nd goods movement call and commit? I think this will ensure that the first commit has been already done.
06-10-2014 8:48 PM
As per my knowledge, it is not advisable to call BAPI_TRANSACTION_COMMIT since it may affect the standard process. Also calling the FM as a separate unit wont fix this problem.