Learn the step-by-step process of how to use a standard BAPI program to perform all mass transactions in SAP Inventory Management. With small variations in settings, you can automate all the goods movement-related transactions in SAP ERP Central Component (SAP ECC) via a single program to perform mass upload and updates. Learn how to use this program via SAP Legacy System Migration Workbench to perform all the Inventory Management transactions.
Key Concept
Legacy System Migration Workbench (LSMW) supports the transfer of data from a non-SAP system to an SAP system or from one SAP system to another SAP system. Using LSMW with a BAPI helps you import data into an SAP system. Goods movement in SAP Inventory Management is a critical area as it directly affects the profitability and revenue of any organization. Sometimes it takes a lot of effort to perform goods movement-related transactions in the SAP system, especially if you have loads of material moving from one place to another. These movements could be the result of the organization receiving raw materials from a supplier, a warehouse issuing goods to meet customer demand, or a company performing an initial stock transfer in a newly created company code, for example. All these transactions require the relevant business user to perform the required postings in goods movement-related transactions. This can take a lot of time as there are many postings and they often have different requirements.
I’ll show you how to use a BAPI program in SAP Legacy System Migration Workbench (LSMW) to perform all these transactions, which will save considerable time for business users in inventory management. Note that it reduces the burden on the technical team as well, but you’ll have to remember to give proper authorizations for the LSMW transaction. I’ll start by explaining the BAPI and how to fit it in LSMW. Then I’ll provide the field structure needed for all the goods movement transactions. I’ll conclude with the settings required to perform a few goods movement transactions with the program.
I won’t cover the basics of LSMW, but you can find more about them in the SAPexperts articles “The Legacy System Migration Workbench – A Guide to Data Migration with BAPIs” by Arthur Wirthensohn and “Reduce Your Reliance on ABAP for Logistics Data Conversion Using LSMW” by Mitresh Kundalia.
Using a BAPI in LSMW
You can call BAPIs via customized programs or by using standard SAP tools such as LSMW. There are two BAPIs for goods movements:
- BAPI_GOODSMVT_CREATE for posting goods movement transactions in the SAP system
- BAPI_GOODSMVT_CANCEL for reversing goods movement transactions in the SAP system
I’ll focus on the first of these.
Step 1. Maintain Object Attributes
The first step in LSMW is to maintain object attributes. Note that before performing this step, you need to execute a few basic settings that are not covered here. Read through the previously mentioned articles and then perform these settings:
- Maintain project, subproject, and object names for LSMW
- Maintain partner numbers and inbound message settings in the partner profile
To see what options are available, use transaction code LSMW and press Enter. Then define project, subproject, and object names and press Enter again. You see a screen with a list of steps in LSMW (Figure 1).

Figure 1
Steps in LSMW
Select Maintain Object Attributes and click the execute icon. This brings up the screen shown in Figure 2, from which you can choose one of the four methods available for uploading data into an SAP system:
- Standard Batch/Direct Input
- Batch Input Recording
- Business Object Method (BAPI)
- IDoc (Intermediate Document)

Figure 2
Four methods for uploading data in LSMW
Which method to use for a particular object depends on your requirements, but if a standard BAPI or IDoc is available, then it’s best to use one of these options. For SAP goods movement transactions, standard business object BUS2017 is available under the BAPI method. Select the Business Object Method (BAPI) radio button and enter the values shown in Figure 3.

Figure 3
Business object details for goods movement
Step 2. Maintain Source Structures
Next define the structure for your source file. For example, you can have one header structure and one item structure (in the case of a purchasing document, you need a header and an item). Select step 2 (Maintain Source Structures) in the screen in Figure 1 and click the execute icon. Then click the display/change icon
followed by the create structure icon
. Enter the name and description of the structure. For goods movement, you only need one structure, as shown in Figure 4.

Figure 4
Define the source structure for goods movement
Step 3. Maintain Source Fields
Select the third step in the screen in Figure 1 (Maintain Source Fields) and click the execute icon. Click the display/change icon and put your cursor on the source structure (MIGO_561). Click the table maintenance icon
and define source fields as shown in Figure 5. The basic field structure covers all the mandatory fields required to post a goods movement in the SAP system.

Figure 5
Source fields for goods movement
You can have more or fewer fields than what I’ve shown based on your requirements. For example, if materials are not maintained in batches in your organization, then you do not need the CHARG – BATCH field. Similarly, if you want your stock to be placed in the Blocked or Quality stock type, you may need to add the INSMK – STOCK TYPE field to your structure.
Here are some details of the fields shown:
- GMCODE: The value against this field defines what type of goods movement needs to be performed. This is a mandatory field.
- BLDAT: This is the date on which you are executing your goods movement program. It is a mandatory field.
- KZBEW: This is a movement indicator field that determines if a goods movement posting is against a purchase order or production order, or is without reference to any document. It is a mandatory field.
- WERKS: This is the plant (valuation area) for which you are posting goods movement. It is usually mandatory, although if you are posting goods movement against a purchase order, this field is not mandatory as the system automatically chooses the plant from the purchase order.
- BUDAT: This is the date on which postings in the system are done as a result of goods movement transactions. It is mandatory.
- ERFMG: This is quantity of stock. It is mandatory unless you are posting goods movement against a purchase order, in which case it is not mandatory as the system automatically picks the quantity from the purchase order.
- CHARG: This is the batch number of material. It is only needed if your company manages stock at batch level.
- MATNR. This is the material number. It is mandatory unless you are posting goods movement against a purchase order, in which case the system automatically picks the material from the purchase order.
- SOBKZ: This is the special stock indicator and only needs to be passed when you are uploading stocks for special stocks such as subcontracting (O) or consignment (K).
- LGORT: This is the storage location under which you want to upload stock in your plant. It is mandatory unless you are posting goods movement against a purchase order, in which case the system automatically picks the storage location from the purchase order.
- LIFNR: This is the vendor number of subcontractor. It only needs to be populated with the subcontractor vendor ID if the value of SOBKZ is O or K.
- MHDAT and VFDAT: These are the production date and shelf life expiry date. They only need to be populated if your material is batch managed.
Other steps and settings in LSMW to run the program are standard and can be learned by going through the LSMW articles I’ve mentioned. I’ll now focus on what settings are needed to run the program for multiple goods movement transactions.
Settings Required to Use the Same Program for Multiple Goods Movement Transactions
You have to let the system know for which goods movement (e.g., goods receipt or goods issue) you are passing the source field values so it can determine which goods movement transactions to post. This is determined by the value of the goods movement code (the GMCODE field in Figure 5) and the movement indicator (the KZBEW field in Figure 5). I’ll show you what value needs to be passed for the GMCODE and KZBEW fields to enable the same program to execute multiple goods movement transactions.
Case 1: Goods Receipt Against a Purchase Order
This is a scenario in which the purchasing department creates a purchase order on the external supplier to fulfill requirements from the production department. Once materials are delivered by the supplier, they have to be received in the SAP system against a corresponding purchase order. For this case, you need to maintain the values shown in Table 1 in LSMW. Table 2 shows fields you need to maintain in your source file.

Table 1
Maintain these values in LSMW

Table 2
Maintain these values in your source file
Case 2: Goods Receipt Without a Purchase Order
This scenario occurs when deliveries are made by the supplier for materials without any purchase order. Maintain the values shown in Table 3 in LSMW and the values shown in Table 4 in your source file.

Table 3
Maintain these values in LSMW

Table 4
Maintain these values in the source file
Case 3: Goods Receipt Against a Production Order
This scenario occurs when you have to receive stock into your warehouse from the production department. For this case, maintain the values in Table 5 in LSMW and the values in Table 6 in your source file.

Table 5
Maintain these values in LSMW

Table 6
Maintain these values in your source file
Note
Other fields such as the batch number, shelf life expiry date (SLED), and stock type are optional. This is because the use of these fields depends on whether the material is managed at batch level in production or if you want to post goods receipt in blocked or quality stock type.
Case 4: Goods Issue for Cost Center
Goods issue is a goods movement that is used to issue material from your plant’s storage location to the production house (cost center). It is basically an outbound movement of material that can be done within your company such as issuing goods from the storage location to fulfill production department requirements or issuing goods from the storage location to fulfill a customer order. I am considering goods issue for the cost center (production department). Enter the values shown in Table 7 in LSMW and Table 8 in your source file.

Table 7
Maintain these values in LSMW

Table 8
Maintain these values in your source file
I used 201 in this example, but note that the BWART value can depend on the scenario. See the examples shown in Table 9.

Table 9
Example BWART values
Case 5: Stock Transfer and Transfer Postings
Transfer postings are used when there is a requirement to move stock from one storage location to another within a plant, across two plants, or across company codes. For this case, maintain the values shown in Table 10 in LSMW. Maintain the values shown in Table 11 in the source file.

Table 10
Maintain these values in LSMW

Table 11
Maintain these values in the source file
The BWART value depends on different scenarios in this case as well. See Table 12 for a few different values that you may need to use.

Table 12
BWART values
Case 6: Initial Stock Upload and All Other Goods Movement
This goods movement occurs when you have to upload stock the first time in a plant. For example, your company might be upgrading from SAP R/3 4.7 to SAP ECC 6.0 and you have to migrate all the stock from the old system to the new system. In such a scenario, you use the initial stock upload process. For this case, and any other goods movement that is not captured above, enter the values in Table 13 in LSMW and the values in Table 14 in the source file.

Table 13
Maintain these values in LSMW

Table 14
Maintain these values in the source file
If materials are batch managed, then you have to populate values for the batch number (CHARG), SLED (VFDAT), and production date (MHDAT) as well.
Yogesh Lohiya
Yogesh Lohiya is a senior SAP MM consultant with Infosys. He is currently working on a large data migration project for a Fortune 500 client. He has more than nine years of consulting experience. He also has worked on various SAP global rollouts and data migration projects in the materials management area.
You may contact the author at ymlohiya@gmail.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.