βš™οΈSAPTools

MSEG: Document Segment: Material

MM

MSEG 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

FieldType / data elementLengthDescription
πŸ”‘MANDTCLNT3Client
πŸ”‘MBLNRMBLNR10Material Document Number
πŸ”‘MJAHRMJAHR4Material Document Year
πŸ”‘ZEILEMBLPO4Item Number
BWARTBWART3Movement Type
MATNRMATNR18Material Number
WERKSWERKS4Plant
LGORTLGORT4Storage Location
MENGEMENGE13Quantity

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

  • MKPF (joined on MBLNR + MJAHR): Header with posting date and user.
  • MARA (joined on MATNR): Cross-plant material master data.
  • MARC (joined on MATNR + WERKS): Plant data of the moved material.
  • EKPO (joined on EBELN + EBELP): Purchase order item behind a goods receipt.

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