Between the function calls we should wait until the object is released by the previous logic unit. Over there we can find solutions like "wait" instruction and also the function module "ENQUEUE_REPORT" which let us know what is locked for the moment this FM is ran.
Following a sample code to determine if a sales document is locked:
lv_repeat = 'Y'.
while lv_repeat = 'Y'.
CALL FUNCTION 'ENQUEUE_REPORT'
EXPORTING
GCLIENT = SY-MANDT
GNAME = ' '
GTARG = ' '
GUNAME = SY-UNAME
IMPORTING
NUMBER = lv_number
SUBRC = lv_subrc
TABLES
ENQ = lt_enq
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
concatenate sy-mandt p_vbeln into lv_key.
read table lt_enq with key garg = lv_key transporting no fields.
if sy-subrc = 0. "if found the object is locked yet
lv_repeat = 'Y'.
else.
lv_repeat = 'N'.
endif.
endwhile.
If you find this useful, please do not hesitate in like and share it!
-------------------------------------------------------------------------------------------------------
Por lo general, durante la construccion de un programa o modulo de funciones tenemos que utilizar múltiples FM, BAPI's o call transactions con el fin de completar un proceso cliente. Por ejemplo la creación de un cliente + orden de venta, o desempaquetar un unidad de empaque en una entrega de salida y desbloqueo para su posterior procesamiento.
Entre las llamadas a funciones que deberíamos esperar hasta que el objeto es liberado por la unidad lógica anterior. Allí podemos encontrar soluciones como usar la instruccion "wait" y también el módulo de función "ENQUEUE_REPORT", que nos dice lo que está bloqueado al momento de su ejecucion.
A continuacion código de ejemplo para determinar si un documento de ventas está bloqueado:
lv_repeat = 'Y'.
while lv_repeat = 'Y'.
CALL FUNCTION 'ENQUEUE_REPORT'
EXPORTING
GCLIENT = SY-MANDT
GNAME = ' '
GTARG = ' '
GUNAME = SY-UNAME
IMPORTING
NUMBER = lv_number
SUBRC = lv_subrc
TABLES
ENQ = lt_enq
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
concatenate sy-mandt p_vbeln into lv_key.
read table lt_enq with key garg = lv_key transporting no fields.
if sy-subrc = 0. "if found the object is locked yet
lv_repeat = 'Y'.
else.
lv_repeat = 'N'.
endif.
endwhile.
Si encuentras este post util, por favor no dudes en darle "like" o compartirlo!
By Jose Antonio Lagonell
No comments:
Post a Comment