Lesson 5 of 6
Data model note: one table for material documents
11 min
Listen to this lesson
Business users can skip table names most of the time, but one inventory change in SAP S/4HANA explains a lot of behavior and a lot of conversion work: material documents are now stored in a single table, MATDOC, and stock quantities are calculated from it.
Before and after
| Topic | SAP ECC | SAP S/4HANA |
|---|---|---|
| Material document header | MKPF | MATDOC (header and item data together) |
| Material document items | MSEG | MATDOC |
| Stock quantities | Stored totals in aggregate tables (per plant, storage location, batch, special stock) | Calculated from MATDOC on the fly |
| Reading old tables | Direct | Through compatibility views that return the same structure |
| Goods movement transactions | MIGO plus MB1A, MB1B, MB1C and others | MIGO and Fiori apps; the old MB posting transactions are replaced by MIGO |
In ECC every goods movement wrote a header row, item rows, and then updated stock totals in several aggregate tables. Those updates were a bottleneck for high-volume postings because each total row had to be locked. In SAP S/4HANA a goods movement inserts rows into MATDOC, and stock is derived from the material documents when someone asks for it. SAP positions this as simpler and faster for posting.
Two technical details are worth knowing when developers or data teams ask. First, the compatibility views have names of their own: reads of MSEG are redirected to a CDS view whose DDL source is NSDM_DDL_MSEG, and the old stock aggregates such as MARD are served the same way (for example NSDM_V_MARD). Second, to keep stock queries fast, SAP S/4HANA keeps a compact extract table, MATDOC_EXTRACT, that the stock CDS views read instead of scanning every material document. SAP documents the change in the simplification item for inventory management data model changes (SAP Note 2206980); read it for your release before a conversion.
What this means for custom reports and programs
Because compatibility views exist, many custom reports that read MKPF, MSEG or stock aggregate tables keep working. Three kinds of custom code need attention:
- Programs that write directly to stock or material document tables. They must be redesigned to use standard posting functions.
- Programs that read large volumes through compatibility views in loops, which can be slow; they may need to read MATDOC or CDS views directly.
- Programs that depend on specific aggregate tables or fields that no longer behave the same way.
During conversion, historical material documents are migrated into MATDOC, so the material document history is still there after go-live. That migration is part of the technical conversion and its runtime is significant for companies with many years of movements. Archiving old material documents before conversion can shorten it.
- Before conversionCustom code checkFind code reading or writing MKPF, MSEG and stock aggregate tables
- Before conversionArchivingArchive old material documents to reduce migration volume
- ConversionData migrationMKPF/MSEG history moved into MATDOC
- After conversionReconciliationStock quantities and values compared with pre-conversion figures
Obsolete MB transactions and what replaces them
| ECC transaction | Purpose | Use in SAP S/4HANA |
|---|---|---|
| MB01, MB0A | Goods receipt for a PO | MIGO (A01, reference Purchase Order) or Post Goods Receipt for Purchasing Document |
| MB1A | Goods issue | MIGO (A07 Goods Issue), for example movement type 201 or 261 |
| MB1B | Transfer posting | MIGO (A08 Transfer Posting) or Transfer Stock - In-Plant / Cross-Plant |
| MB1C | Other goods receipts | MIGO (A01, reference Other), for example 501 or 561 |
| MB11 | Goods movement (general) | MIGO |
| MB31 | Goods receipt for a production order | MIGO (reference Order) or the confirmation |
| MB51, MB52, MB5B, MMBE | Reports | Still available; Fiori apps sit alongside them |
The MB posting transactions are replaced by MIGO (SAP Note 1804812). Reports such as MB51 and MB5B remain.
Clean core adds a forward-looking rule for Kenji's team: new extensions should read inventory through SAP's released CDS views and APIs (in ABAP Development Tools, check a view's API state before you build on it), not through MATDOC or the compatibility views directly. A Z report that selects from MSEG may still run after the conversion, but it is the kind of object the custom code cleanup should retire or rebuild.
What would you do?
A developer says Contoso's custom stock report must be rewritten because "MSEG doesn't exist anymore in S/4HANA." Is that accurate?
For day-to-day users little changes: MIGO, MMBE and the Fiori stock apps work as before, and material document numbers keep their format. The difference shows in conversion work and in technical reports. If your team owns custom stock reports, interfaces that read goods movements or extracts to a data warehouse, list them now and ask for each: does it only read, how much data does it read, and has its output been compared after conversion?
- Material documents are stored in MATDOC; MKPF and MSEG are replaced.
- Stock quantities are calculated from material documents, not stored in aggregate tables.
- Compatibility views keep many reads working; direct writes must be redesigned.
- Reconcile stock quantities, values and custom reports across the conversion.
- The MB posting transactions are obsolete: post with MIGO or the Fiori apps.
Check your understanding · not graded
Lesson check
1. Which table stores material documents in SAP S/4HANA?
2. How are stock quantities determined in SAP S/4HANA?
3. Which custom code needs the most urgent redesign?
4. What happens to historical material documents at conversion?