MSEG: Document Segment: Material
MMMSEG holds the line items of material documents: one row for each goods movement line, with the movement type, material, plant, storage location and quantity. The document header with the posting date and the user is in MKPF.
Primary key
MBLNR + MJAHR + ZEILE
plus the client field
Module
MM
Fields in this reference
9
How the MSEG key works
The primary key is MANDT, MBLNR, MJAHR and ZEILE. A material document number is only unique together with the document year MJAHR.
MSEG fields
| Field | Type / data element | Length | Description |
|---|---|---|---|
| πMANDT | CLNT | 3 | Client |
| πMBLNR | MBLNR | 10 | Material Document Number |
| πMJAHR | MJAHR | 4 | Material Document Year |
| πZEILE | MBLPO | 4 | Item Number |
| BWART | BWART | 3 | Movement Type |
| MATNR | MATNR | 18 | Material Number |
| WERKS | WERKS | 4 | Plant |
| LGORT | LGORT | 4 | Storage Location |
| MENGE | MENGE | 13 | Quantity |
This is a curated subset of the most commonly used fields, not the complete table definition. A real system contains more fields and can differ by release and customizing, so confirm the definition in transaction SE11 before relying on it.
Example ABAP SELECT for MSEG
" Open SQL applies the client (MANDT) automatically, so it is not part of the WHERE clause.
DATA lv_mblnr TYPE mseg-mblnr.
DATA lv_mjahr TYPE mseg-mjahr.
SELECT zeile, bwart, matnr, werks
FROM mseg
WHERE mblnr = @lv_mblnr
AND mjahr = @lv_mjahr
INTO TABLE @DATA(lt_mseg).Modern Open SQL with host variables (ABAP 7.40 and later). Need a different field list or conditions? Build it in the ABAP SELECT Builder.
MSEG in SAP S/4HANA
In current SAP S/4HANA releases, material documents are stored in the table MATDOC. MKPF and MSEG remain available as compatibility views, but new development should read MATDOC or the released CDS views.
Tables related to MSEG
Practical tips for MSEG
- BWART (movement type) tells you what happened, for example 101 for a goods receipt against a purchase order, 261 for a goods issue to a production order and 601 for a goods issue for a delivery. Reversals use related types, for example 102 for 101.
- MENGE is unsigned. The debit/credit indicator SHKZG decides whether the movement increases the stock (S) or decreases it (H).
- The posting date and the user are stored in the header table MKPF, so join it when you need to filter by period.
MSEG FAQ
What is a movement type in SAP?
A three-character key (BWART) that controls how a goods movement is posted, for example 101 for a goods receipt against a purchase order or 601 for a goods issue for a delivery.
What is the primary key of MSEG?
MANDT, MBLNR, MJAHR and ZEILE: the material document number, the document year and the line item.
Keep exploring
- SAP Table Field Lookup: search all 28 tables and their fields.
- SAP BAPI Explorer: find the BAPI that creates or changes this data.
- CDS View Generator: expose these tables through a CDS view.