10-16-2008 1:54 PM
Good morning experts,
i need to use the bapi BAPI_MATERIAL_SAVEDATA to change Costing 2 data.
I would like to DEQUEUE if the material is locked, what is the function?
i tried the functions below but the material still locked.
CALL FUNCTION 'ENQUEUE_EMMARAE'
EXPORTING
MODE_MARA = 'E'
MANDT = SY-MANDT
MATNR = IN_TB_COSTING-matnr
X_MATNR = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
CALL FUNCTION 'DEQUEUE_EMMARAE'
EXPORTING
MODE_MARA = 'E'
MANDT = SY-MANDT
MATNR = IN_TB_COSTING-matnr.
ENDIF.
CALL FUNCTION 'ENQUEUE_EMMARCE'
EXPORTING
MODE_MARC = 'E'
MANDT = SY-MANDT
MATNR = IN_TB_COSTING-matnr
WERKS = IN_TB_COSTING-werks
X_MATNR = ' '
X_WERKS = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
CALL FUNCTION 'DEQUEUE_EMMARCE'
EXPORTING
MODE_MARC = 'E'
MANDT = SY-MANDT
MATNR = IN_TB_COSTING-matnr
WERKS = IN_TB_COSTING-werks.
ENDIF.
CALL FUNCTION 'ENQUEUE_EMMBEWE'
EXPORTING
MODE_MBEW = 'E'
MANDT = SY-MANDT
MATNR = IN_TB_COSTING-matnr
BWKEY = IN_TB_COSTING-werks
BWTAR =
X_MATNR = ' '
X_BWKEY = ' '
X_BWTAR = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
CALL FUNCTION 'DEQUEUE_EMMBEWE'
EXPORTING
MODE_MBEW = 'E'
MANDT = SY-MANDT
MATNR = IN_TB_COSTING-matnr
BWKEY = IN_TB_COSTING-werks.
thanks
10-16-2008 2:13 PM
Hi,
Are you talking about dequeue your own lock??????and if not, how can you dequeue anybody else lock...
I believe you are following the flow...
Request Lock/Enqueue
Do the Changes
Release Lock/Dequeue
10-16-2008 2:29 PM
use the Function BAPI_TRANSACTION_COMMIT , instead of using the dequeue. after the BAPI call based on the return message type , call the Function BAPI_TRANSACTION_COMMIT
10-16-2008 3:31 PM
I mens i f tohe material is locked by another user, i can unlock the material and do the changes?
thanks
10-16-2008 3:36 PM
You don't mess with other people's locks. If they've locked a material it's for a reason, unlocking it and making any changes could do a lot of damage. Make a log of locked materials and reprocess once the lock is released.
10-20-2008 8:27 AM
ok thanks all, i won't try to dequeue lock of other users.
Bye
Marco