10-12-2008 2:01 PM
Hi there,
I have a problem I'm using a BAPI for reversing an production confirmation. This BAPI creates to a goods movement (MSEG). I make directly after the call of the BAPI a Commit Work (with the BAPI-FM).
So now I have to select the table AFWI which contains the value of the created material document (MSEG-MBLNR). But I do not get the correct number. It seems that I select a temporary-number and after a few seconds then the correct number is saved in the database table. I think the creation of the number is done by the SAP in a V2-execution (asyncron).
But now my question: Which options do I have to get the correct number? For testing I have implemented a WAIT-statement with 2 seconds, but I can not gurantee that this time will always be enough. What if there are may update records to be handled in this time?
What can I do to really always get the correct document number?
Thanks a lot!
Kind regards
Max
Edited by: Max Maier on Oct 12, 2008 3:02 PM
10-12-2008 2:17 PM
Hi,
Looks Strange......Are you using the FM BAPI_TRANSACTION_COMMIT after your BAPI? If that is the case then you will always get the Correct Document Number......Getting a temporary number looks different to me...
10-12-2008 2:17 PM
Hi,
Looks Strange......Are you using the FM BAPI_TRANSACTION_COMMIT after your BAPI? If that is the case then you will always get the Correct Document Number......Getting a temporary number looks different to me...
10-12-2008 2:21 PM
Hi,
yes I use this function module. Here a fragment of my coding:
* BAPI to reverse/cancel the production confirmation
CALL FUNCTION 'BAPI_PROCORDCONF_CANCEL'
EXPORTING
confirmation = iv_conf
confirmationcounter = iv_counter
IMPORTING
return = ls_return
locked = lv_locked
created_conf_no = ev_conf
created_conf_count = ev_counter.
* Error in Processing
IF ls_return-type = 'E' OR
ls_return-type = 'A'.
MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number
WITH ls_return-message_v1 ls_return-message_v2
ls_return-message_v3 ls_return-message_v4
INTO me->log_dummy.
me->log_add_message( me->log_normal ).
EXIT.
* Locked state
ELSEIF lv_locked = 'X'.
MESSAGE e017(zh) WITH iv_conf iv_counter
INTO me->log_dummy.
me->log_add_message( me->log_normal ).
EXIT.
* Sucessfull processing
ELSE.
MESSAGE s018(zh) WITH iv_conf iv_counter
INTO me->log_dummy.
me->log_add_message( me->log_normal ).
ENDIF.
* Making COMMIT WORK
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
* Addition wait is necessary so that the right material document can be
* selected
WAIT UP TO 2 SECONDS.
* Selection of material document created by BAPI
SELECT * FROM afwi
INTO TABLE lt_afwi
WHERE rueck = ev_conf
AND rmzhl = ev_counter.
I can see the incorrect doc number because I write the result of the selection in a own Z-Table, and there I can see the number selected by the statement:
0000001763
0000001752
--> created incorrect numbers (and also the document year is initial in this case)
a correct doc number would be for example: 4900250619 (with doc year 2008)
Edited by: Max Maier on Oct 12, 2008 3:21 PM
Edited by: Max Maier on Oct 12, 2008 3:24 PM
11-01-2008 9:06 PM
12-04-2008 6:30 AM
Hi Max
Can you please explain more in detail how you solved this problem.
Thanks.