on ‎2021 May 21 11:38 AM
What is the best way to lock/enqueue an object even after the code that created the lock ends. Only an explicit dequeue call on that object should be able to unlock/dequeue that object.
I want to dequeue only if the transaction is completed. Currently my code is working in the case when we are in the process of
Any idea or solution would be greatly appreciated.
here is my code..
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
* GCLIENT = SY-MANDT
gname = 'ISEG'
* GARG = ' '
* guname = sy-uname
* LOCAL = ' '
* FAST = ' '
* GARGNOWC = ' '
* IMPORTING
* NUMBER =
* SUBRC = '0'
TABLES
enq = enq
EXCEPTIONS
communication_failure = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
** Implement suitable error handling here
ENDIF.
IF enq is INITIAL.
CALL FUNCTION 'ENQUEUE_EZTESTLOCK'
EXPORTING
MODE_ISEG = 'X'
MANDT = SY-MANDT
iblnr = lv_iblnr
gjahr = lv_gjahr
* X_IBLNR = ' '
* X_GJAHR = ' '
_scope = '3'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
ELSE.
CONCATENATE iblnr lv_gjahr INTO ld_garg SEPARATED BY space.
LOOP AT enq INTO wa_enq WHERE garg CS ld_garg.
EXIT.
ENDLOOP.
CHECK sy-subrc EQ 0.
IF wa_enq-guname EQ sy-uname.
ls_entityset-zmessage = |User | && sy-uname && | blocks physical inventory document | && ld_garg .
APPEND ls_entityset TO et_entityset.
ENDIF.
***************OPTIONAL
EXIT.
************End Enque
ENDIF.
Request clarification before answering.
Scope '3' should do the trick, but I have experienced similar problems. Is your program executing without GUI context, e.g. as a web service implementation or in a background job?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.