12-23-2011 10:08 AM
Dear Friends at SCN,
I have the following problem when using the bapi BAPI_PRODORDCONF_CREATE_TT, that is called several times in the same program:
the first run completes successfully, and then there is a call to BAPI_TRANSACTION_COMMIT.
with the second, and the remaining ones, usually the BAPI returns an error saying 'Reservation xxxxx is already being processed'.
I believe I should release the Reservation, after the first bapi call, and before the next one, but how to achieve that?
Do you have a clue how to avoid this error appearing?
Thanks a lot for any help or suggestion on this.
Bye,
Flavio
12-23-2011 10:28 AM
Are you trying to create multiplereservations? if yes please make sure you have put in a wait for 1or 2 seconds please have cleared all the bapi parameters after the call of BAPI.
Nabheet
12-23-2011 10:28 AM
Are you trying to create multiplereservations? if yes please make sure you have put in a wait for 1or 2 seconds please have cleared all the bapi parameters after the call of BAPI.
Nabheet
12-23-2011 1:55 PM
Hi Nabheet,
Thank you for your answer.
I just tried adding a WAIT UP TO 2 SECONDS and a clear / refresh of bapi parameters (after the call), but the error message is still appearing.
Do you have any other idea for this?
Thanks again!
Bye,
Flavio
01-03-2012 10:51 AM
Solved:
before calling the BAPI, just added a locking check on Reservation (by means of ENQUEUE_EMRESB and DEQUEUE_EMRESB FM's, in a 60 sec's time-limited loop), that proved to be successful.
Thank you and bye
Flavio
03-30-2014 7:50 PM
Hello Flavio,
I have the same problem as you have already experienced. Could you, please, give me a little detail that I managed to implement this function.
thank you,
Stephane
03-31-2014 12:23 PM
Hi Stéphane,
Here is the code I used, just before calling the BAPI:
DATA: l_lock(1) TYPE c,
l_while TYPE i.
* Check if Reservation is locked, if yes wait for unlocking
l_lock = 'X'.
l_while = 0.
WHILE l_lock = 'X'.
CALL FUNCTION 'ENQUEUE_EMRESB'
EXPORTING
mode_resb = 'E'
rsnum = l_rsnum
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
l_lock = 'X'.
WAIT UP TO 1 SECONDS.
l_while = l_while + 1.
ELSE.
CLEAR l_lock.
CALL FUNCTION 'DEQUEUE_EMRESB'
EXPORTING
mode _resb = 'E'
rsnum = l_rsnum.
EXIT.
ENDIF.
IF l_while = 60.
EXIT.
ENDIF.
ENDWHILE.
I hope it will help.....
Thank you and bye,
Flavio