How To Goods Movements With BAPI
How To Goods Movements With BAPI
Link to this Page Link Tiny Link Wiki Markup Close Move Page How
Recently View ed There w ere no re Know n Location The specified pag Brow se Error reading the
You could try relo HTTP Status You must make a Failed to retrieve There w ere no pa Show ing <b>{0}<
Move failed. Ther You cannot move How To Goods M MM-IM-GF-BAPI ERPSCM
ERP SCM You cannot move Page Ordering Back Reorder Move
88113270
view
Content
1. Content
2. BAPIs in Inventory Management
3. Introduction
4. Data population
5. Further information
6. Which fields must be populated during the various transactions/events?
7. GM_Code 01: Goods receipt for purchase order
1. Purchase order known
2. Purchase order unknown: Shipping notification known
3. Purchase order unknown: Purchase order is to be created automatically
4. Purchase order unknown: A purchase order is not to be created
1. Transfer of subcontracting components
8. GM_Code 02: Goods receipt for production order
9. GM_Code 03: Goods issue
1. Goods issue without reference to a reservation
2. Goods issue with reference to a reservation
10. GM_Code 04: Transfer posting
1. Transfer posting without reference to a reservation
11. GM_Code 05: Other goods receipts
12. GM_Code 06: Reversal of goods movements
13. GM_Code 07: Subsequent adjustment with regard to a subcontract order
14. More information on LINE_ID and PARENT_ID
1. An application that calls the BAPI_GOODSMVT_CREATE BAPI, has the following
choices:
15. Additional fields in goods-receipt-based invoice verification
16. How to test he BAPI
17. Example Code for calling the GM BAPI to post a 561 Goods Movement
18. Calling the BAPI several times within one roll area
1. Here you have to adhere to the following procedure:
2. Example 1:
3. Example 2:
19. SAP Notes
Introduction
You can use the BAPI BAPI_GOODSMVT_CREATE to create a material document for a goods movement. You
can only create one material document each time you call up the method. You can use a simulation function
before posting the goods movement to check how the data is updated in the database. The standard system
is configured so that the goods movement is posted immediately, without prior simulation.
Data population
Ensure that you transfer the data in the same way as it is managed in the database.
For example:
The following information about the material document that is to be created is passed on to the
BAPI:
Confirmations
Messages are returned in the Return parameter. The parameter documentation shows the return codes and
their meanings.
Further information
The BAPI can only perform your function if no error messages were generated in the Return table. This is the
case if the header data and all the items were processed successfully.
Transaction control is not implemented. The calling program therefore has to execute the Commit Work itself
after this method has been successfully invoked (in other words, if no errors were reported in the Return
parameter).
When calling the Goods Movement BAPI you have to specify a Goods Movement Code. The
following codes are possible:
The following fields may have to be populated (this is not a complete list):
• Stock type
• Item text
• Unloading point
• Delivery completed indicator
• The following fields must not be populated (this is not a complete list):
• Account assignment fields (the account assignment is adopted from the purchase order)
• Reservation
• Receiving/issuing material
• Receiving/issuing plant
• Receiving/issuing storage location
In the case of a purchase order item with the item category "subcontracting", only the GR item is to be
passed on in the interface. The GI items are determined automatically in the system.
• Delivery
• Delivery item
• Movement type
Other fields as under "Purchase order known". The system determines the relevant purchase order item via
the delivery/delivery item.
• Material number
• Plant
• Storage location
• Vendor
• Movement type
• Movement indicator
• Quantity in unit of entry
• ISO code unit of measurement for unit of entry
The following fields may have to be populated (this is not a complete list):
• Stock type
• Item text
• Unloading point
You cannot populate the following fields (this is not a complete list):
• Account assignment fields (automatic creation of purchase order items with account assignment is not
supported)
• Reservation
• Receiving/issuing material
• Receiving/issuing plant
• Receiving/issuing storage location
• Material number
• Plant
• Storage location
• Vendor
• Movement type
• Movement indicator
• Quantity in unit of entry
• ISO code unit of measurement for unit of entry
The following fields may have to be populated in some cases (this is not a complete list):
• Account assignment fields (automatic creation of purchase order items with account assignment is not
supported)
• Reservation
• Receiving/issuing material
• Receiving/issuing plant
• Receiving/issuing storage location
• Receiving/issuing batch
The input combinations listed above for the GM_CODE 01 can be combined within an input table so that they
can be posted in a material document. Items can also be posted for different purchase orders, provided that
all the purchase orders relate to the same vendor.
• All other fields in the method that are included in this list.
• All fields that are not included in the list above. The movement indicator must be initial.
• Additional fields in goods-receipt-based invoice verification
• When you post a goods receipt to purchase order with movement type 102, an issue with reference to a
previously posted goods issue, the following fields must also be transferred:
• REF_DOC_IT (LFPOS): Item of a reference document
• REF_DOC (LFBNR): Document number of a reference document
• REF_DOC_YR (LFBJA): Fiscal year of a reference document
• Only if you transfer these fields can you be sure that the link to the original goods movement is retained.
• Order
• Movement type
• Movement indicator
• Quantity in unit of entry
• ISO code unit of measurement for unit of entry or quantity proposal
The following fields may have to be populated in some cases (this is not a complete list):
• Account assignment fields (the account assignments are adopted from the purchase order)
• Reservation
• Receiving/issuing material
• Receiving/issuing plant
• Receiving/issuing storage location
• Receiving/issuing batch
• Material number
• Plant
• Storage location
• Movement type
• Movement indicator
• Quantity in unit of entry
• ISO code unit of measurement for unit of entry
• The following fields may have to be populated in some cases (this is not a complete list):
• Special stock (e.g. sales order, project, vendor etc.)
• Minimum shelf life expiration date (if set up in the system)
• Reason for movement (if set up in the system)
• Batch (if the material is handled in batches and automatic batch number assignment is not set)
• Account assignment fields
• Reservation
• Receiving/issuing material
• Receiving/issuing plant
• Receiving/issuing storage location
• Receiving/issuing batch
The following fields may have to be populated in some cases (this is not a complete list):
• Movement type
• Material
• Plant
• Account assignment fields
• Material number
• Plant
• Storage location
• Movement type
• Movement indicator
• Quantity in unit of entry
• ISO code unit of measurement for unit of entry
The following fields may have to be populated in some cases (this is not a complete list):
• Receiving material
• Receiving plant
• Receiving storage location
• Receiving batch (if material is handled in batches and you want to change batches)
• Receiving/issuing special stock (e.g. sales order, project, vendor etc.)
• Minimum shelf life expiration date (if set up in the system)
• Reason for movement (if set up in the system)
• Batch (if the material is handled in batches and automatic batch number assignment is not set)
• Reservation
• Transfer posting with reference to a reservation
• See goods issue with reference to a reservation
If you want to cancel a goods movement with reference to a reservation (without using the Cancel method)
you can only transfer the BAPI_GM_ITEM_CREATE_XSTOB field if it is populated. Movement types are not
transferred when you post with reference to a reservation, as the movement type is contained in the
reservation item.
Components
• All fields that are not in the list above. The movement indicator must be blank.
These two fields define the hierarchie levels of all items. To import the data for the subcontracting
components, these fields must have entries. All information about the goods movement to be posted is
transferred to BAPI BAPI_GOODSMVT_CREATE using the BAPI2017_GM_ITEM_CREATE structure.
• Only transfer of end product (ordered material of subcontract order) with movement type 101, all
components are therefore read with the ME_READ_COMP_GOODS_RECEIPT function.
• Transfer of end product (ordered material of subcontract order) and components, the components are posted
with the data from the BAPI2017_GM_ITEM_CREATE (BAPI communication structure: Create material
document item) structure.
• Subsequent adjustment, the end product and all components must be transferred to the
BAPI_GOODSMVT_CREATE BAPI.
How for the last two cases the BAPI2017_GM_ITEM_CREATE structure is to be filled, is explained in the
following examples.
In the following, you will find a list of fields mentioned in the following examples. The name of the particular
field in the interface is specified in brackets.
Examples
LINE_I PARENT_I MATERIA PLAN STGE_LO ENTRY_QN MOVE_TYP MVT_IN PO_NUMBE PO_ITE
D D L T C T E D R M
Subsequent adjustment
LINE_I PARENT_I MATERIA PLAN STGE_LO ENTRY_QN MOVE_TYP MVT_IN PO_NUMBE PO_ITE
D D L T C T E D R M
Note that
the ENTRY_QNT field can be negative in subsequent adjustment. This is then allowed if a goods receipt
instead of a goods issue is posted for a component. In the BAPI for the MVT_IND field, the special stock
indicator O is supported.
In the example above, only a few fields are used, although the BAPI2017_GM_ITEM_CREATE structure has
over one hundred fields. Only a few of these fields are useful for subcontracting components; they can be
found in the GOCOMP (Components for subcontracting) structure (see this list).
Example Code for calling the GM BAPI to post a 561 Goods Movement
ZBAPI_GDSMVT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT z_bapi_gdsmvt.
START-OF-SELECTION.
ls_mmdochdr-doc_date = p_docdat.
ls_gm-move_type = '561'.
ls_gm-material = p_matnr.
ls_gm-plant = p_plant.
ls_gm-stge_loc = p_sloc.
ls_gm-entry_qnt = p_quant.
ls_gm-batch = p_batch.
CLEAR ls_gm.
* Call BAPI
EXPORTING
goodsmvt_header = ls_mmdochdr
goodsmvt_code = '05'
IMPORTING
goodsmvt_headret = ls_hdr
TABLES
goodsmvt_item = lt_gm
return = lt_ret.
* If no error, commit
IF lt_ret IS INITIAL.
EXPORTING
wait = 'X'.
* Alternative COMMIT WORK.
ELSE.
WRITE: ls_ret-type,
ls_ret-id,
ls_ret-number,
ls_ret-message,
ls_ret-log_no,
ls_ret-log_msg_no,
ls_ret-message_v1,
ls_ret-message_v2,
ls_ret-message_v3,
ls_ret-message_v4.
ENDLOOP.
ENDIF.
Make sure that the program buffer is deleted by changing the roll area. You can accomplish this by logging
off and then logging in again for the BAPI process. If the BAPI is called from an ABAP program, you can also
use the command
Example 1:
Test
Program Test.
...
LOOP.
....
....
ENDLOOP.
Func1
FUNCTION func1.
....
...
IF 'no errors'.
ELSE.
ENDIF.
...
ENDFUNCTION.
Example 2:
ZBAPI_GDSMVT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zbapi_gdsmvt.
* DATA: ...
* PARAMETERS: ...
START-OF-SELECTION.
* If no error, commit
EXPORTING
wait = 'X'.
* ELSE
* Error handling
EXPORTING
destination = 'NONE'.
* If no error, commit
EXPORTING
wait = 'X'.
* ELSE
* Error handling
EXPORTING
destination = 'NONE'.
Caution!
The commit work executed in func1 processes all function modules of DESTINATION 'NONE' that were called
in 'update task'.If function modules in 'update task' are called in the calling program, these do not lead to a
database update.In this case, you have to execute a further commit work in the calling program.
SAP Notes
• 520813 FAQ Note for GM with BAPIs