Material Document Migration: MSEG/MKPF to MATDOC
How SAP S/4HANA consolidates material document header (MKPF) and item (MSEG) tables into MATDOC, and which CDS Views to use for goods movements.
What Changed?
In SAP ECC, material documents (goods receipts, goods issues, transfer postings) were stored in two tables: MKPF (Material Document Header) and MSEG (Material Document Items). S/4HANA merges both into a single table: MATDOC.
MATDOC combines header and item data into one row per line item. Header fields (posting date, user, etc.) are denormalized onto every item row. This design leverages HANA's columnar compression — repeated header values compress efficiently — and eliminates header-to-item joins.
Table Migration Overview
| ECC Table | Purpose | S/4HANA Status |
|---|---|---|
| MKPF | Material Document Header | Compatibility view on MATDOC |
| MSEG | Material Document Items | Compatibility view on MATDOC |
| MATDOC | Material Document (Header + Item) | New primary table |
Key Field Mapping: MSEG/MKPF to MATDOC
| MSEG/MKPF Field | MATDOC Field | Description |
|---|---|---|
| MKPF-MBLNR | MBLNR | Material Document Number |
| MKPF-MJAHR | MJAHR | Material Document Year |
| MSEG-ZEILE | ZEILE | Item Number |
| MKPF-BUDAT | BUDAT | Posting Date |
| MKPF-USNAM | USNAM | User Name |
| MSEG-BWART | BWART | Movement Type |
| MSEG-MATNR | MATNR | Material Number |
| MSEG-WERKS | WERKS | Plant |
| MSEG-LGORT | LGORT | Storage Location |
| MSEG-MENGE | MENGE | Quantity |
| MSEG-MEINS | MEINS | Unit of Measure |
| MSEG-EBELN | EBELN | Purchase Order Number |
| MSEG-EBELP | EBELP | Purchase Order Item |
| MSEG-LIFNR | LIFNR | Vendor |
CDS Views for Material Documents
SAP provides CDS Views as the recommended access layer:
- I_MaterialDocumentItem — Material Document Items (primary replacement for MSEG reads)
- I_MaterialDocumentHeader — Material Document Header data
- I_MaterialDocumentItem_2 — Extended material document item view
- I_InventoryAmtInCoCdCrcy — Inventory values in company code currency
ABAP Code Migration Example
Before (ECC — joining MKPF and MSEG):
SELECT m~mblnr m~mjahr m~zeile m~matnr m~werks
m~bwart m~menge m~meins k~budat k~usnam
FROM mseg AS m
INNER JOIN mkpf AS k
ON m~mblnr = k~mblnr
AND m~mjahr = k~mjahr
INTO TABLE @DATA(lt_matdoc)
WHERE k~budat IN @s_budat
AND m~werks = '1000'.
After (S/4HANA — using CDS View):
SELECT MaterialDocument, MaterialDocumentYear,
MaterialDocumentItem, Material, Plant,
GoodsMovementType, QuantityInBaseUnit,
MaterialBaseUnit, PostingDate, CreatedByUser
FROM I_MaterialDocumentItem
WHERE PostingDate IN @s_budat
AND Plant = '1000'
INTO TABLE @DATA(lt_matdoc).
The join between MKPF and MSEG becomes unnecessary because MATDOC (and the CDS View) already contains both header and item fields.
Impact on BW Extractors
The classic BW extractor 2LIS_03_BF (Goods Movements) was based on MSEG. In S/4HANA, SAP provides CDS-based extraction views as replacements:
- I_MaterialDocumentItemCube — Analytics-enabled view with
@Analytics.dataExtraction.enabled: true - See the BW Extractor to CDS View Migration Guide for the complete mapping
- Browse all extractors on the Extractor Map page