‎2006 Jul 17 10:26 AM
Hello i use ffunction module
CALL FUNCTION 'BAPI_PRODORDCONF_CREATE_TT'
EXPORTING
post_wrong_entries = lv_post
testrun = lv_testrun
IMPORTING
return = ls_bapiret1
TABLES
timetickets = lt_bapi_pp_timeticket
goodsmovements = lt_bapi2017_gm_item_create
link_conf_goodsmov = lt_bapi_link_conf_goodsmov
detail_return = lt_bapi_coru_return.
in loop. SOmetimes in diferenet production ordes (MTO MTS) i confim the same material data. ALthough i USE ENQUE DEQUE logic to avoid locks, sometimes after it in COGI i have errors Plant data for material.... blocked by user. What am i missing ??
To avoid locks i use something like that:
LOOP AT lt_bapi2017_gm_item_create INTO
ls_bapi2017_gm_item_create.
GET RUN TIME FIELD t_1.
d_t = 0.
sy-subrc = 9.
WHILE d_t <= 600000000 AND sy-subrc <> 0.
CALL FUNCTION 'ENQUEUE_EMRKPF'
EXPORTING
MODE_RKPF = 'E'
MANDT = SY-MANDT
rsnum = ls_bapi2017_gm_item_create-reserv_no
X_RSNUM = ' '
_SCOPE = '2'
_wait = 'X'
_COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
GET RUN TIME FIELD t_2.
d_t = t_2 - t_1.
ENDWHILE.
GET RUN TIME FIELD t_1.
d_t = 0.
sy-subrc = 9.
WHILE d_t <= 600000000 AND sy-subrc <> 0.
CALL FUNCTION 'ENQUEUE_EMMARCE'
EXPORTING
MODE_MARC = 'E'
MANDT = SY-MANDT
matnr = ls_bapi2017_gm_item_create-material
werks = ls_bapi2017_gm_item_create-plant
X_MATNR = ' '
X_WERKS = ' '
_SCOPE = '2'
wait = gcx
_COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3
.
GET RUN TIME FIELD t_2.
d_t = t_2 - t_1.
ENDWHILE.
CALL FUNCTION 'DEQUEUE_EMMARCE'
EXPORTING
matnr = ls_bapi2017_gm_item_create-material
werks = ls_bapi2017_gm_item_create-plant
_synchron = 'X'.
COMMIT WORK AND WAIT.
CALL FUNCTION 'DEQUEUE_EMRKPF'
EXPORTING
rsnum = ls_bapi2017_gm_item_create-reserv_no
_synchron = 'X'.
COMMIT WORK AND WAIT.
ENDLOOP.
Any help will be apriciaited. I am stuck with that 😕
BR, Jacek
Message was edited by: Jacek Slowikowski
Message was edited by: Jacek Slowikowski
Message was edited by: Jacek Slowikowski
‎2006 Jul 17 10:35 AM
Hello Jacek,
There is no need the take care of the locking mechanism explicitly. Since BAPI will take care of the locking mechanism automatically.
If useful reward points.
Vasanth
‎2006 Jul 17 10:39 AM
That is not so simple.
Imagine we have 3 records with te same material to confirm.
In effect that bapi in background triggers Material movement, which locks that materil and may not be finished befroe second trigger of BAPI is done. So i need to check locks before Bapi triggering. But something is now working 😕
Message was edited by: Jacek Slowikowski
.
Message was edited by: Jacek Slowikowski
Message was edited by: Jacek Slowikowski
‎2006 Jul 17 12:11 PM
Hey,
If you need to check if a particular object is locked use the function ENQUEUE_READ with proper parameters and introduce a WAIT if the object is locked. Sample code below:
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
gclient = sy-mandt
gname = p_tablename
garg = p_tablekey
IMPORTING
number = p_number
subrc = p_subrc
TABLES
enq = pt_enq
EXCEPTIONS
communication_failure = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc NE 0.
*
ELSE.
IF p_number GT 0.
WAIT UP TO 2 SECONDS.
ENDIF.
ENDIF.
After the function 'BAPI_PRODORDCONF_CREATE_TT' call the BAPI "BAPI_TRANSACTION_COMMIT" with wait as X.
-Kiran
Message was edited by: Kiran Raorane