Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
paul_gendreau
Contributor
You can load inventory quantity and value for materials in S/4HANA 2020 using IDoc Type MBGMCR04.

Yes, SAP S/4HANA Migration Cockpit is the “recommended by SAP” tool for loading data in S/4HANA. But there are exceptions to its efficacy. For example, IDoc type MBGMCR is exactly how it’s done in SAP Rapid Data Migration with SAP Data Services (On Premise), Migration Inventory Balances (‏W38‏).

If you’re not using SAP Data Services then Legacy System Migration Workbench (LSMW) is also relevant, using exactly the same IDoc approach that SAP delivers with Rapid Data Migration. What’s more, LSMW (more precisely, IDocs) remains essential for data migration in SAP Retail. For confirmation of necessity, see SAP Note 2538170 – Migration of Retail Objects to SAP S/4HANA on-premise.

MDA Workbench is a free and simple tool for creating such LSMW projects, and for creating a comprehensive kit of deliverables for data migration.

Let’s have a look, using data migration of inventory quantity and value for material as an example.

MDA Workbench can be downloaded here, and the MDA Workbench project file for this example can be downloaded here. With these, you can easily reproduce the data migration deliverables outlined in this article.

But the deliverables are useful, as is, without MDA Workbench! That's the point. This is an example of creating functional and technical data migration content that's reusable, and it's been unit tested in S/4HANA 1909.

MDA Workbench Creates a Kit of Deliverables


The beauty of having an MDA Workbench Project File (data migration content) is that it supports reusability (from project to project) and so easily accommodates changes in requirements. After all, data migration is an iterative process!

Either way and any way, as requirements change, you open the project file, make changes to the selected segments and fields, maintain sample data, and Publish an up-to-date kit of functional and technical deliverables.

Choose the relevant IDoc Segments and Fields, maintain sample data, and then click the Publish button in MDA Workbench.


MDA Workbench: Choose IDoc segments and fields. Then click Publish


 


MDA Workbench: Maintain Sample Data for Unit Testing


 

Here’s a link to a Zip file named MDA_MATINV.ZIP with the Kit of Deliverables created by MDA Workbench. There are five files in the Zip file.

MDA_MATINV_20201019-164020.MDAWB is a project file that can be opened with MDA Workbench.

  • It was saved as a backup when I clicked the Publish button in MDA Workbench, together with the 4 other files.

  • You can open this file, adjust it if needed, and click the Publish button in MDA Workbench to produce a new Kit of Deliverables.


MDA_MATINV_20201019-164020.XLSX is the beautiful field-level mapping workbook created by MDA Workbench.

  • Worksheet SAP FIELD MAP includes IDoc field-level details, including SAP Help Text for data elements. It defines the field-level mapping into the IDoc.

  • Worksheet MDA_MATINV01_DATA includes sample data (maintained in MDA Workbench) for the Load Ready File to be used as input for unit testing the LSMW Project.


MDA_MATINV_LSMW_PROJECT_02_20201019-164020.TXT is the LSMW project created by MDA Workbench.

  • This LSMW project was tested in S/4HANA 1909.

  • Import the LSMW Project into your SAP system and it’s ready to run!


MDA_MATINV_SQL_20201019-164020.TXT is a database script created by MDA Workbench.

  • If you’re using a staging database (e.g. SQL Server, Oracle, DB2, etc.) to prepare Load-Ready Files for data migration, then this script can be used to create the staging database table.


MDA_MATINV01_DATA_20201019-164020.TXT is the sample data file created by MDA Workbench.

  • This is the Load-Ready File with data used to test the LSMW Project.

  • It’s the same data as found in the field-level mapping workbook, Worksheet MDA_MATINV01_DATA.


 

Load Inventory Balance using MBGMCR04


Let’s look at the relevant IDoc segments and fields. This data migration object is really simple, with very few inputs.

Segment E1MBGMCR – Header Segment
















Field Name Field Description Comment
TESTRUN Switch to Simulation Session for Write BAPIs Segment E1MBGMCR is mandatory and this is the only field in the segment. Be certain that it’s mapped with a blank value.


Segment E1BP2017_GM_HEAD_01 – BAPI Communication Structure: Material Document Header Data
















Field Name Field Description Comment
PSTNG_DATE Posting Date in the Document Entry must be 8 digits (YYYYMMDD).


Segment E1BP2017_GM_CODE – MMIM: New Key Assignment GM_CODE to Transaction of Inv. Mgmt
















Field Name Field Description Comment
GM_CODE Assign code to transaction for BAPI goods movement

Expected Value: 06

01 – MB01 – Goods receipt for purchase order
02 – MB31 – Goods receipt for production order
03 – MB1A – Goods issue
04 – MB1B – Transfer posting
05 – MB1C – Other goods receipt
06 – MB11 – Reversal of goods movements
07 – MB04 – Subsequent adjustment with regard to a subcontract order


Segment E1BP2017_GM_ITEM_CREATE – BAPI Communication Structure: Create Material Document Item














































Field Name Field Description Comment
MATERIAL Material Number (18 Characters)
PLANT Plant
STGE_LOC Storage location Mandatory Entry; 4 Characters
MOVE_TYPE Movement type (inventory management) Mandatory Entry; Expected value: 561
ENTRY_QNT Quantity in unit of entry
ENTRY_UOM_ISO ISO code for unit of measurement

Unit of Measure in ISO.

Unit of Measure in Load Ready files should be specified using the ISO code, not Internal Unit and not Displayed Unit.  They are typically the same, but differ for some Units of Measure For example, carton, CT (ISO Unit) should be used and neither CAR (Commercial Unit) nor KAR (Internal Unit) should be used.

Refer to table T006I for the list of ISO codes.
AMOUNT_LC Externally entered posting amount in local currency Enter the total value for the ENTRY_QTY.   Moving Price will be calulated based on ENTRY_QTY / AMOUNT_LC.


 

State Before Unit Test


The unit test example is for Material M_CR_1001 and Plant CU00, adding 100 pieces with a value of $500.00.


T-Code MM43 before load, for Material M_CR_1001 and Plant CU00.


 


T-Code MMBE before load, for Material M_CR_1001 and Plant CU00.


 

Load-Ready File


The sample data was maintained in MDA Workbench, and included in the field-mapping workbook as Worksheet MDA_MATINV01_DATA:


Worksheet MDA_MATINV01_DATA


 

The same example data was included a tab-delimited Load-Ready File named MDA_MATINV01_DATA_20201019-164020.TXT:


MDA_MATINV01_DATA_20201019-164020.TXT


 

We’ll rename MDA_MATINV01_DATA_20201019-164020.TXT to MDA_MATINV01.TXT, put the file in folder C:\DATA, and use that as the Load-Ready file to test the LSMW program.

 

Unit Test



  • LSMW Project: MDA – Master Data Aficionado

  • LSMW Sub Project: MATINV – Material Inventory

  • LSMW Object: 4700 INV – Inventory Quantity and Value


In LSMW, choose More > Settings > Inbound IDoc Processing. Maintain the partner function for inbound message type MBGMCR and process code BAPI.

 


T-Code LSMW: Inbound IDoc Processing Settings – Partner Profile


 

Execution of the LSMW creates two IDocs:


T-Code WE02 shows two IDoc MBGMCR04 processed.


 

Let’s look at the segments of the first IDoc in detail:


Segment E1MBGMCR – Header Segment


 


Segment E1BP2017_GM_HEAD_01 – BAPI Communication Structure: Material Document Header Data


 


Segment E1BP2017_GM_CODE – MMIM: New Key Assignment GM_CODE to Transaction of Inv. Mgmt


 


Segment E1BP2017_GM_ITEM_CREATE – BAPI Communication Structure: Create Material Document Item


 

After Unit Test


Inventory quantity and value are updated.

 


T-Code MM43 after load, for Material M_CR_1001 and Plant CU00.


 


T-Code MMBE after load, for Material M_CR_1001 and Plant CU00.


 

Reference