What is SAP MKPF / MSEG?
MKPF and MSEG are the SAP ECC tables that store material document headers and items for every goods movement.
MKPF and MSEG are the SAP tables that store material documents in ECC: MKPF holds the header and the MSEG table holds one line per item of every goods movement. Together they record what stock moved, where, when and why, and they are archived with MM_MATBEL.
How MKPF and MSEG work
Every goods receipt, issue, transfer or stock correction creates one MKPF header keyed by material document number (MBLNR) and year (MJAHR). Each item lands in MSEG with material, plant, storage location, movement type (BWART), quantity and value. Accounting documents in BKPF and BSEG are linked to the same movement.
Because each line is kept forever unless archived, MSEG is usually one of the largest tables in a logistics-heavy ECC system. Transactions MIGO and MB51 read these tables directly.
- MKPF: posting date, document date, user, transaction code, reference.
- MSEG: material, plant, batch, movement type, quantity, amount in local currency, PO reference.
- Linked tables: BKPF and BSEG for the accounting side.
How to archive MKPF and MSEG with MM_MATBEL
- Run a table size analysis (for example DB02 or TAANA) to see MSEG volume by year and plant.
- In SARA, enter MM_MATBEL and open Customizing to set residence times per plant and transaction type.
- Create a write variant, start with test mode on, and restrict by year and plant.
- Run the write job in production mode during a low-posting window.
- Run the delete job and check the job log for skipped documents.
- Activate an archive information structure for MM_MATBEL in SARI so archived documents remain readable.
- Store archive files in the linked content repository and confirm they are retrievable.
Archiving needs S_ARCHIVE authorization for MM_MATBEL. Avoid running write and delete in parallel with period-end stock postings.
Key parameters
| Parameter or field | What it controls | Recommended setting or note |
|---|---|---|
| Residence time | Minimum age before archiving | Align with audit and inventory valuation needs |
| Transaction or event type | Which movements are included | Review goods receipts tied to open POs separately |
| Plant | Scope of the run | Archive one plant first to test |
| Test mode | Simulation without writing files | Always run once before production mode |
| Archive infostructure | Read access after deletion | Activate before the delete run, not after |
MKPF / MSEG vs related objects
| Object | Purpose | When to use it | Status |
|---|---|---|---|
| MKPF / MSEG | Material document header and items | ECC systems | Replaced in S/4HANA |
| MATDOC | Single material document table | S/4HANA | Current |
| MM_MATBEL | Archiving object for material documents | ECC and S/4HANA | Current |
| EKBE | PO history including goods receipts | Purchasing history | Current |
| BSEG | Accounting line items of the movement | Financial view | Current |
Common issues and troubleshooting
Why is MSEG still large after MM_MATBEL archiving?
Residence times were not met for most documents, or the variant excluded plants. Check the write log for documents skipped as not archivable and review residence settings per transaction type.
Why does MB51 not show archived material documents?
MB51 reads the database by default. Archived documents need an active MM_MATBEL infostructure in SARI and selection of the archive as a data source.
Why is the delete job slow on MSEG?
Missing statistics or large index fragmentation. Update statistics before deletion and reorganize indexes afterward.
MKPF / MSEG in S/4HANA migration and decommissioning
Material documents are the evidence behind inventory valuation, cost of goods sold and customs declarations. Auditors ask for them when stock values or excise duty are challenged, so they must be retained after an ECC system is retired.
During conversion, MKPF and MSEG content is migrated into MATDOC. Every year carried over increases conversion runtime and HANA memory. Leaving history behind without a retention plan is the opposite risk: the trail behind historic stock values disappears. Archive closed years before conversion and keep them readable in an independent SAP archiving. Measure MSEG rows by year and plant.
- Decide which years move to MATDOC and which are archived.
- Keep the link between material and accounting documents in the archive.
- Confirm MB51-style search works on archived data.
- Validate stock totals before and after conversion.
Frequently asked questions
What is the SAP MSEG table?
The SAP MSEG table stores the item lines of material documents in ECC. Each row records one goods movement line: material, plant, storage location, movement type, quantity and value. It is paired with header table MKPF and is archived with the MM_MATBEL archiving object.
What replaces MKPF and MSEG in S/4HANA?
In SAP S/4HANA, both tables are replaced by MATDOC, a single table that holds header and item data. MKPF and MSEG remain as compatibility views so custom code can still read them, but new postings are written only to MATDOC.
How do I reduce the size of the MSEG table?
Archive closed material documents with MM_MATBEL after residence times are met. Run test mode first, archive by plant and year, and activate an archive infostructure so the documents remain searchable. Deleting rows directly in the database breaks audit trails and is not supported.
Do material documents need to be kept after decommissioning?
Usually yes. They support inventory valuation, cost of goods sold and customs or excise records, which fall under financial retention rules in most jurisdictions. Retain them in a searchable archive with the linked accounting documents before the system is switched off.
Further reading
See Also
Ready to put this into practice?
See how Archon helps organizations with compliant archiving and legacy decommissioning.