Page tree
Skip to end of metadata
Go to start of metadata


The purpose of this page is to clarify how the cancellation of material documents works with BAPI processing.


In the below section two examples are provided to show how the cancellation of material documents with BAPI GOODSMVT_CREATE / GOODSMVT_CANCEL works. The first case refers to the scenario, when the total quantity is reversed, in the second scenario the quantity is only partially reversed.

Full reversal

If the whole material document has to be cancelled BAPI_GOODSMVT_CANCEL should be used.

Step 1 : Go to transaction SE37 and execute with the sequence BAPI_GOODSMVT_CANCEL -> BAPI_TRANSACTION_COMMIT. Commit should be executed in order to confirm the booking. For further details about this commit work please see note ’457499 - No material document generated for BAPI BAPI_GOODSMVT_CREATE’.

The year and the number of the material document that should be cancelled has to be entered, then the posting date. If all mandatory data is entered, the transaction should be executed.

If the reversal document creation was successful the export parameter with the material document number and year appears on the screen. The final step is to execute the commit after stepping back.

According to the defined sequence the function module ’ BAPI_TRANSACTION_COMMITis called. It has to be executed as well.

If there are no errors issued during the processing, the return export parameter will appear as ’000’ and it indicates that the booking happened. The reversal document is stored in MSEG.

To finalize, step back, a pop-up is executed and go on with ’Save’.

Case 2 – Partial reversal

If the original material document should be reversed only partially (for example only part of the whole quantity has to be reversed), BAPI_GOODSMVT_CREATE should be used, as with BAPI_GOODSMVT_CANCEL it is not possible to change any data in the document that is to be reversed (like decreasing the quantity).

BAPI has to be executed with the same logic as with the full reversals. The sequence BAPI_GOODSMVT_CREATE / BAPI_TRANSACTION_COMMIT should be entered in SE37 (path: Function module / Execute / Test sequences)

Data should be entered as for a non reversal movement, further details can be found on the printscreen below.

(Prerequisite: Two material documents with the movement 161 were booked for a purchase order, one of the material documents has to be reversed partially.)

Purchase order:

BAPI Processing:

Header data: Posting date and document date has to be filled. Reference document is the number of the document that should be cancelled.

Goods movement code: It depends on the movement code of the material document that is to be cancelled. In this scenario the original document was booked with movement type 161, which belongs to movement code 01, accordingly the reversal also has the movement code 01.

Item data: It is advised to enter the data as detailed as possible. In this scenario the material, movement type (reversal movement type), quantity (to be reversed), PO number and PO item should be filled. Movement indicator depends on the referred document, in this case the movement 161 was booked with reference to PO, so the field has to be filled with ’B’.

If the data is maintained, after execution a screen with the export paramteres shows up, which contains the number of the created material document. After stepping back the commit has to be executed and saved.


Related Content

Related SAP Notes/KBAs

520813 - FAQ: BAPIs for goods movements

407265 - Transfer parameter with BAPI BAPI_GOODSMVT_CANCEL



Use this structure to help you compose your contributions for WIKI and at the same time will ensure spelling and grammar.