SAP Good Movement BAPI: SAP MM-IM offers a package of SAP Good Movement BAPIs to read, update or create Material Document.
Usually, the relative SAP Good Movement BAPI for Good Movement start with BAPI_GOODSMVT_*.
Table of Contents
Let’s start with SAP Good Movement BAPI to create a Material Document.
The BAPI to consider is BAPI_GOODSMVT_CREATE. This BAPI will post goods movements.
Within BAPI_GOODSMVT_CREATE there is a call to the standard function module MB_CREATE_GOODS_MOVEMENT which generate the SAP Material Doument.
Here ABAP code showing how to create in ABAP program a SAP Material Document with the Standard BAPI_GOODSMVT_CREATE.
PS: This code is not mine, check the source here. You can use as a template for your ABAP Program using this SAP BAPI.
* Structures for BAPI data: gm_header type bapi2017_gm_head_01, gm_code type bapi2017_gm_code, gm_headret type bapi2017_gm_head_ret, gm_item type table of bapi2017_gm_item_create with header line. data: gm_return type bapiret2 occurs 0. data: gm_retmtd type bapi2017_gm_head_ret-mat_doc. clear: gm_return, gm_retmtd. refresh gm_return. * Setup BAPI header data. gm_header-pstng_date = sy-datum. gm_header-doc_date = sy-datum. gm_code-gm_code = '06'. " MB11 * Write 551 movement to table clear gm_item. move: '551' to gm_item-move_type , '000000000040001234' to gm_item-material, '1' to gm_item-entry_qnt, 'EA' to gm_item-entry_uom, '0004' to gm_item-plant, '4000' to gm_item-stge_loc, '201' to gm_item-move_reas. * Determine cost center per plant case xresb-werks. when '0004'. move '0000041430' to gm_item-costcenter. when '0006'. move '0000041630' to gm_item-costcenter. when '0007'. move '0000041731' to gm_item-costcenter. when '0008'. move '0000041830' to gm_item-costcenter. endcase. append gm_item. * Call goods movement BAPI call function 'BAPI_GOODSMVT_CREATE' exporting goodsmvt_header = gm_header goodsmvt_code = gm_code importing goodsmvt_headret = gm_headret materialdocument = gm_retmtd tables goodsmvt_item = gm_item return = gm_return. call function 'BAPI_TRANSACTION_COMMIT' exporting wait = 'X'.
You can find an other sample ABAP program reading a file and creating SAP Material Document for each line of the file here.
A common business case (for example in SAP PM Plant Management or SAP QM for Quality Management), you may have to create document material in SAP not for the material itself but for Equipment.
Actually, SAP Equipment is identified both by :
The same SAP BAPI situed above BAPI_GOODSMVT_CREATE can make the job.
You have just to fill the table GOODSMVT_SERIALNUMBER with list of Equipments.
Find an ABAP Code Sample to create a Material Document with multiple equipment for a material
(Create single Material Document with Multiple Equipment)
Read more about
In order to reverse Goods Movements, use the standard BAPI BAPI_GOODSMVT_CANCEL.
SAP BAPI will call in its processing the fm MB_CANCEL_GOODS_MOVEMENT responsible to cancelling an existing SAP Good Movement.
You can cancel the whole Good Movement as you can partially can the Material Document.
You have to set some additional information as:
Don’t forget to call a ‘BAPI_TRANSACTION_COMMIT’ to commit modification to Database.
The BAPI BAPI_GOODSMVT_GETDETAIL will display Details for Material Document.
It is very helpful if you want to get a quick overview ( in ABAP ) of the Material Document.
and The output are:
The BAPI BAPI_GOODSMVT_GETITEMS will display a detailed List of Material Documents.
This BAPI are more Search BAPI. Acutally in input you can fill tables with range of value for
And the Return of the BAPI_GOODSMVT_GETITEMS are two tables with the list of :
July 12, 2018 January 21, 2020
Function and Translation" width="323" height="215" />
December 21, 2017 January 21, 2022
December 19, 2017 January 21, 2020