‎2010 Dec 22 1:35 PM
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
OBJECTKEY = LV_OBJECTKEY
OBJECTTABLE = 'MCHA'
CLASSNUM = 'BATCH_01'
CLASSTYPE = '022'
IMPORTING
CLASSIF_STATUS = CLASSIF_STATUS
TABLES
ALLOCVALUESNUMNEW = IT_VALUES_NUM
ALLOCVALUESCHARNEW = IT_VALUES_CHAR
ALLOCVALUESCURRNEW = IT_VALUES_CURR
RETURN = IT_BAPIRET2.
IF CLASSIF_STATUS = 1.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = WA_BAPIRET2.
ELSE.
CALL FUNCTION 'C14ALD_BAPIRET2_SHOW'
TABLES
I_BAPIRET2_TAB = IT_BAPIRET2
.
ENDIF.IT_BAPIRET2 return error message:
Object is currently locked by user.
The assigment was not changed
currently, no user to change batch's characteristics.
How to solve this problem??
‎2010 Dec 22 2:57 PM
Hi,
I was confused with your question. Check whethere some body is editing the current entry. and change your code like this
The user name will be there in the return table. you can identify who is locking the entry. when you are passing WAIT = 'X'
there will not be any problem. It will be synchronous.
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
OBJECTKEY = LV_OBJECTKEY
OBJECTTABLE = 'MCHA'
CLASSNUM = 'BATCH_01'
CLASSTYPE = '022'
IMPORTING
CLASSIF_STATUS = CLASSIF_STATUS
TABLES
ALLOCVALUESNUMNEW = IT_VALUES_NUM
ALLOCVALUESCHARNEW = IT_VALUES_CHAR
ALLOCVALUESCURRNEW = IT_VALUES_CURR
RETURN = IT_BAPIRET2.
read table IT_BAPIRET2 with key type = 'E' transporting no fields.
if sy-subrc ne 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = WA_BAPIRET2.
ELSE.
CALL FUNCTION 'C14ALD_BAPIRET2_SHOW'
TABLES
I_BAPIRET2_TAB = IT_BAPIRET2 .
ENDIF.
‎2010 Dec 22 2:05 PM
Hi cpliu903
You can try to put "wait up to..." statement after first fm. It should fix the problem .
Best Regards
Yossi Rozenberg
‎2010 Dec 22 2:11 PM
It should locked by you only. Please check the code , you just execute the bapi and if the classification status is not 1 you are doing something. In the mean time your process is not completed.
‎2010 Dec 22 2:43 PM
Loop at MAT_ITEM.
call -> BAPI_OBJCL_CHANGE
if classification status = 1
commit.
else
popup error.
endloop
This is whole flow. please see the image. that is capture from SM12
[http://img193.imageshack.us/img193/4613/lockyo.png|http://img193.imageshack.us/img193/4613/lockyo.png]
‎2010 Dec 22 2:53 PM
I had same problem.
The usual commit work and wait is not enought.
You should add more time for the operation to end it's processes and remove locks.
If you will add wait up to lets say 3 seconds at end of each loop run - you will see if this is the problem.
and then find your own logic to optimize the run time
Best Regards
Yossi
‎2010 Dec 22 2:34 PM
‎2010 Dec 22 2:57 PM
Hi,
I was confused with your question. Check whethere some body is editing the current entry. and change your code like this
The user name will be there in the return table. you can identify who is locking the entry. when you are passing WAIT = 'X'
there will not be any problem. It will be synchronous.
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
OBJECTKEY = LV_OBJECTKEY
OBJECTTABLE = 'MCHA'
CLASSNUM = 'BATCH_01'
CLASSTYPE = '022'
IMPORTING
CLASSIF_STATUS = CLASSIF_STATUS
TABLES
ALLOCVALUESNUMNEW = IT_VALUES_NUM
ALLOCVALUESCHARNEW = IT_VALUES_CHAR
ALLOCVALUESCURRNEW = IT_VALUES_CURR
RETURN = IT_BAPIRET2.
read table IT_BAPIRET2 with key type = 'E' transporting no fields.
if sy-subrc ne 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = WA_BAPIRET2.
ELSE.
CALL FUNCTION 'C14ALD_BAPIRET2_SHOW'
TABLES
I_BAPIRET2_TAB = IT_BAPIRET2 .
ENDIF.