Guide

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 TablePurposeS/4HANA Status
MKPFMaterial Document HeaderCompatibility view on MATDOC
MSEGMaterial Document ItemsCompatibility view on MATDOC
MATDOCMaterial Document (Header + Item)New primary table

Key Field Mapping: MSEG/MKPF to MATDOC

MSEG/MKPF FieldMATDOC FieldDescription
MKPF-MBLNRMBLNRMaterial Document Number
MKPF-MJAHRMJAHRMaterial Document Year
MSEG-ZEILEZEILEItem Number
MKPF-BUDATBUDATPosting Date
MKPF-USNAMUSNAMUser Name
MSEG-BWARTBWARTMovement Type
MSEG-MATNRMATNRMaterial Number
MSEG-WERKSWERKSPlant
MSEG-LGORTLGORTStorage Location
MSEG-MENGEMENGEQuantity
MSEG-MEINSMEINSUnit of Measure
MSEG-EBELNEBELNPurchase Order Number
MSEG-EBELPEBELPPurchase Order Item
MSEG-LIFNRLIFNRVendor

CDS Views for Material Documents

SAP provides CDS Views as the recommended access layer:

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:

Related Resources