What is SAP MATDOC?

MATDOC is the SAP S/4HANA table that stores material documents, replacing MKPF and MSEG with a single table.

MATDOC is the SAP S/4HANA table that stores material documents, holding header and item data for every goods movement in a single table. It replaces the ECC tables MKPF and MSEG, also replaces several stock aggregate tables, and is archived with the MM_MATBEL archiving object.

How MATDOC works

In ECC, a goods movement wrote a header to MKPF, items to MSEG and updated stock aggregates such as MARD and MCHB. In S/4HANA, the movement is written once to MATDOC. Stock quantities are calculated from MATDOC, supported by MATDOC_EXTRACT for performance, instead of being stored in separate totals tables.

To keep custom code working, MKPF, MSEG and the old aggregate tables are available as compatibility views that read MATDOC. Transactions MIGO and MB51 continue to work against the new model.

  • One row per material document item, with header fields repeated.
  • Additional fields capture stock type and stock identifiers.
  • Old names remain readable through views but writes go only to MATDOC.

How to analyze and archive MATDOC

  1. Size MATDOC by year and plant with DB02, TAANA or SE16N on key fields.
  2. In SARA, enter MM_MATBEL and maintain residence times under Customizing.
  3. Create a write variant by plant and closed years and run test mode.
  4. Run production write and delete in a low-posting window.
  5. Activate an MM_MATBEL infostructure in SARI for read access.
  6. Validate stock values before and after the run in a test system first.

Users need S_ARCHIVE for MM_MATBEL. Coordinate with inventory teams before archiving plants with open physical inventory.

Key parameters

Parameter or field What it controls Recommended setting or note
MBLNR / MJAHR / ZEILE Document, year, item Primary lookup key
BWART Movement type Basis for transaction type residence rules
WERKS / LGORT Plant and storage location Archive by plant to test
Residence time (MM_MATBEL) Age before archiving Keep audit years online
Archive infostructure Read access Build before deletion
Object Purpose When to use it Status
MATDOC Material documents S/4HANA Current
MKPF / MSEG Material documents ECC Replaced; compatibility views in S/4HANA
MATDOC_EXTRACT Supports stock calculation S/4HANA performance Current
MARD / MCHB Stock aggregates ECC Compatibility views in S/4HANA
MM_MATBEL Archiving object ECC and S/4HANA Current

Common issues and troubleshooting

Why does a custom program reading MSEG run slowly in S/4HANA?

MSEG is now a view over MATDOC. Selections without key fields or with many joins become expensive. Read MATDOC directly or use released CDS views.

Why is MATDOC growing faster than MSEG did?

MATDOC carries header fields on every line and absorbs data previously held in aggregates. Archive closed years with MM_MATBEL.

Why did the conversion to MATDOC take so long?

Every unarchived MKPF and MSEG row is migrated. Archiving closed years before conversion is the main lever.

MATDOC in S/4HANA migration and decommissioning

Material documents support inventory valuation, cost of goods sold and customs records. MATDOC concentrates that evidence in one large table, which makes it both valuable and expensive in memory.

Two risks stand out. Before conversion, migrating every historical MSEG row inflates runtime and HANA sizing. After later consolidations or system retirements, MATDOC history can be stranded if no one owns it. Archive by year, keep the link to accounting documents, and use an SAP S/4HANA migration archive for history outside the active window.

  • Archive closed MKPF and MSEG years before conversion.
  • Size MATDOC growth per year after go-live.
  • Keep material documents linked to FI documents.
  • Validate stock values around every archiving run.
  • Plan retention for MATDOC when the S/4HANA system itself is later consolidated.

Frequently asked questions

What is the SAP MATDOC table?

The SAP MATDOC table is the S/4HANA table for material documents. It stores header and item data for each goods movement in one table and replaces MKPF, MSEG and several stock aggregate tables from ECC. It is archived with the MM_MATBEL archiving object.

Do MKPF and MSEG still exist in S/4HANA?

Yes, but only as compatibility views. They read data from MATDOC so existing reports and custom code keep working. New postings are written only to MATDOC, so performance-critical code should read MATDOC or released CDS views directly. Avoid broad selections on the views.

How do I reduce MATDOC table size?

Archive closed material documents with MM_MATBEL after residence times are met. Run test mode first, archive by plant and year, and build an archive infostructure for read access. Archiving MKPF and MSEG history before conversion also prevents MATDOC from starting oversized.

Should MATDOC data be retained after a system is retired?

Yes, in most cases. Material documents support inventory valuation and cost of goods sold for earlier years, and some support customs or excise records. Retain them with linked accounting documents in a searchable archive. Keep plant and material master data so lines can be interpreted.

Further reading

See Also

Ready to put this into practice?

See how Archon helps organizations with compliant archiving and legacy decommissioning.

Talk to us →

Archon © 2026, All rights reserved.