cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering a second Material Movement for the same material (322 after 632)

quiquec
Explorer
0 Kudos

Hello.

We need to make a 322 after a 632 in order to move to Quality as the material comes from "Customer consignment" .

I have tried to call 'BAPI_GOODSMVT_CREATE' inside BADI~MB_DOCUMENT_UPDATE to trigger automatically 322 but it isn't working as the 632 is in process (COMMIT problem).

Any ideas how to do the second material document?

Thank you very much in advanced.

View Entire Topic
DominikTylczyn
Active Contributor

Hello quiquec

If I were you, I would automate the second material document posting with output determination. You can set up a custom output type and determine it with the first material document. Then you put all the posting logic to create the second document into the output processing routine. This approach has a couple advantages:

- you can store any messages coming from the second document posting into the output processing log with the NAST_PROTOCOL_UPDATE function

- if anything goes wrong with the second material document posting, you can easily monitor that with standard SAP transaction and reprocess the output

- you can set up output determination very flexible way to make sure the second document is posted only for the right first documents.

On top of that, as you have the posting logic already implemented in the BAdI, it will be very easy to port it to the output determination processing.

Once you do that, you need to make sure that the second document is posted in a separate logical unit of work (LUW) from the first one. Otherwise you'll hit the problem you already have. That can be achieved in two ways:

- either process the output with processing time 3, i.e. not immediately when the first document is posted

- or process the output with processing time 4 i.e. immediately with the first document posting but redirect the processing to a separate LUW using the following piece of code:

* (0) Redirect this NAST processing to separate LUW - in case it is
*     called with processing time 4 (Immediate) in the update task
  CALL FUNCTION '/SPE/CALL_PROC_IN_NEW_LUW'
    EXPORTING
      is_nast  = nast
    IMPORTING
      ef_leave = lf_leave.

  IF NOT lf_leave IS INITIAL.
* Per default we set the status on error, so that it can be reprocessed
* in error processing (RSNAST0F) if there is any syntax error / update
* termination / ... in the decoupled NAST processing.
    rc = 4.
    EXIT.
  ENDIF.

That code comes from the /SPE/STO_ID_PROCESSING program, STO_ID_CREATION, which processes SPED output type and creates an inbound delivery from an outbound one in stock transfer scenarios.

Best regards

Dominik Tylczynski

quiquec
Explorer

Thank you very much. Very good solution.