‎2013 Jul 04 1:55 PM
Hi Experts,
I have a requirement to automatically trigger a GI with movement type 910 when a GR with movement type 101 is done against a Purchase order(PO). And after that i need to create a document for the sub material with movement types 909 and 343.
When i am using the BADI : MB_DOCUMENT_BADI.
After posting the 101 movement type it is showing the error as valuation data is locked by the user (same user).
How can i achieve this?
Your inputs are highly appreciated.
Regards,
Anvesh
‎2013 Jul 04 7:54 PM
My bad idea, is to create a batch input. Create a function that try 3 times to launch the batch-input .. if it failes. Create a job that launch the batch input.
I have already do this horrific method for problem like your. That's not beautiful, but it works.
regards
fred
‎2013 Jul 04 7:54 PM
My bad idea, is to create a batch input. Create a function that try 3 times to launch the batch-input .. if it failes. Create a job that launch the batch input.
I have already do this horrific method for problem like your. That's not beautiful, but it works.
regards
fred
‎2013 Jul 05 6:02 AM
Hi Fred,
Thanks for your inputs.
For this if you have any sample code please send me, it is very helpful.
many thanks,
Anvesh
‎2013 Jul 05 8:44 AM
Yep,
the program call the function with the enqueue (lock / unlock object)
And you need also a job that launch the batch-input not finished.
Regards
Fred
The function :
FUNCTION zbc_bdc_submit_locked.
*"----------------------------------------------------------------------
*"*"Interface locale :
*" IMPORTING
*" VALUE(IT_ENQUEUE) TYPE WLF_SEQG3_TAB OPTIONAL
*" VALUE(W_UNAME) TYPE SYUNAME
*" VALUE(W_MAXWAIT) TYPE SYTABIX OPTIONAL
*" VALUE(W_NOM) TYPE APQ_GRPN
*"----------------------------------------------------------------------
DATA : gw_flag_wait(1) ,
is_enq TYPE seqg3 ,
is_bdc TYPE bdcdata ,
it_enq TYPE wlf_seqg3_tab WITH HEADER LINE.
* Si pas de limit d'attente, limite passé à 5 tours.
IF w_maxwait IS INITIAL.
MOVE 5 TO w_maxwait.
ENDIF.
* Vérifie qu'aucune entrée de blocage marché ne tourne.
DO w_maxwait TIMES.
* Recherche des entrées de blocage sur le user.
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
gclient = sy-mandt
guname = w_uname
TABLES
enq = it_enq
EXCEPTIONS
OTHERS = 3.
* Recherche si entrée de blocage du user correspond à celui marqué
* pour le batch.
LOOP AT it_enqueue
INTO is_enq.
READ TABLE it_enq
WITH KEY gname = is_enq-gname
garg = is_enq-garg.
IF sy-subrc EQ space.
MOVE 'X' TO gw_flag_wait.
ENDIF.
ENDLOOP.
IF sy-subrc NE space.
EXIT.
ENDIF.
IF gw_flag_wait EQ space.
EXIT.
ELSE.
WAIT UP TO 20 SECONDS.
CLEAR gw_flag_wait.
ENDIF.
ENDDO.
IF gw_flag_wait EQ space.
SUBMIT rsbdcsub WITH mappe = w_nom
WITH von = sy-datum
WITH bis = sy-datum
EXPORTING LIST TO MEMORY
AND RETURN.
ENDIF.
ENDFUNCTION.
‎2013 Jul 05 3:08 PM
In which method of the BAdI did you try to create the new movements ? Most (if not every) methods are before COMMIT WORK, so before records are unlocked, so you have to delay execution after unlock,
One solution is to wrap the following BAPI/BDC execution after the end of the update tasks triggered by the commit :
Wrap your new movement and document creation in a RFC enabled FM, and call this FM IN BACKGROUND TASK. It will execute after release of locks by the end of the update task.
Regards,
Raymond