Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Alternative for WAIT-Statement

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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...

4 REPLIES 4

Former Member
0 Kudos

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...

0 Kudos

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

Former Member
0 Kudos

I inserted a check on the created document to proof it manually

0 Kudos

Hi Max

Can you please explain more in detail how you solved this problem.

Thanks.