SAP Reference
MB31
Create S/4HANA status: ReplacedGoods Receipt for Production Order
Notes
Classic goods-movement transaction; SAP recommends MIGO as the unified goods-movement transaction in S/4HANA.
What the badges mean
- S/4HANA status: Active
- Active and unchanged in S/4HANA.
- S/4HANA status: Deprecated
- Still readable today, but no longer SAP's strategic path — plan around it.
- S/4HANA status: Replaced
- Replaced by a new persistence in S/4HANA; the classic name may still answer reads (see read mechanism).
- S/4HANA status: Migrating to IBP
- Planning scope is moving from APO toward IBP.
- S/4HANA status: Active (StRM) · Replaced (EWM)
- Path-dependent: active with SAP Stock Room Management, replaced where EWM is the warehouse path.
- S/4HANA status: Replaced · Compat View
- Compatibility view: the classic table name is redirected to a view over the new persistence — see how the physical model moved.
- S/4HANA status: Active · Proxy View
- Proxy view: reads route through NSDM proxy/CDS views — see how the physical model moved.
- master
- Data class: what the table holds — master data, transaction documents, org structure, config, or texts (one row per language — see the quirks guide).
In field listings, K marks a primary-key field, and linked type codes in the Type column jump to the matching quirks-guide section.
Boilerplate SQL
Databricks SQLStarting point for querying the tables behind this transaction. Set your Unity Catalog location and filter values below — they’re substituted into the SQL and the copy button.
Query parameters
7 parameters not filled: <catalog>, <schema>, <MANDT>, <DATE_FROM>, <DATE_TO>, <WERKS>, <MATNR>
-- ============================================================
-- T-Code : MB31 Goods Receipt for Production Order
-- Purpose: Post goods receipt from a production order (movement types 101/131)
-- Grain : One row per material document item (MKPF + MSEG)
-- Tables : MKPF, MSEG, MAKT, MARA, T001W, T001L, LFA1
-- Notes : SHKZG = 'H' (credit) movements flip the quantity negative on paired reports like MB51. On S/4HANA, read MATDOC directly instead of MKPF+MSEG for better S/4HANA-native performance and semantics; benchmark in your system.
-- ============================================================
SELECT
-- Keys
h.MANDT AS "Client",
h.MBLNR AS "Material Document",
h.MJAHR AS "Material Doc Year",
l.ZEILE AS "Item",
-- Descriptive text
mt.MAKTX AS "Material Description",
h.BKTXT AS "Header Text",
-- Quantities + UOM (paired)
CASE WHEN l.SHKZG = 'H' THEN (l.MENGE * -1) ELSE l.MENGE END AS "Quantity (Signed)",
l.MEINS AS "Unit of Measure",
l.DMBTR AS "Amount in Local Currency",
l.WAERS AS "Currency",
-- Dates
h.BUDAT AS "Posting Date",
h.BLDAT AS "Document Date",
h.CPUDT AS "Entered On",
-- Status / indicators
l.BWART AS "Movement Type",
l.SHKZG AS "Debit/Credit Indicator",
l.XAUTO AS "Auto-Created Flag",
l.SMBLN AS "Reversal Document",
-- Org fields
l.WERKS AS "Plant",
pt.NAME1 AS "Plant Name",
l.LGORT AS "Storage Location",
sl.LGOBE AS "Storage Location Name",
l.BUKRS AS "Company Code",
-- Master data enrichment
l.MATNR AS "Material Number",
m.MTART AS "Material Type",
m.MATKL AS "Material Group",
l.CHARG AS "Batch",
l.EBELN AS "Purchase Order",
l.EBELP AS "PO Item",
l.AUFNR AS "Order Number",
l.KDAUF AS "Sales Order",
l.LIFNR AS "Vendor",
vnd.NAME1 AS "Vendor Name",
h.USNAM AS "User Name"
FROM <catalog>.<schema>.mkpf h
INNER JOIN <catalog>.<schema>.mseg l
ON l.MANDT = h.MANDT
AND l.MBLNR = h.MBLNR
AND l.MJAHR = h.MJAHR
LEFT JOIN <catalog>.<schema>.makt mt
ON mt.MANDT = l.MANDT
AND mt.MATNR = l.MATNR
AND mt.SPRAS = 'E'
LEFT JOIN <catalog>.<schema>.mara m
ON m.MANDT = l.MANDT
AND m.MATNR = l.MATNR
LEFT JOIN <catalog>.<schema>.t001w pt
ON pt.MANDT = l.MANDT
AND pt.WERKS = l.WERKS
LEFT JOIN <catalog>.<schema>.t001l sl
ON sl.MANDT = l.MANDT
AND sl.WERKS = l.WERKS
AND sl.LGORT = l.LGORT
LEFT JOIN <catalog>.<schema>.lfa1 vnd
ON vnd.MANDT = l.MANDT
AND vnd.LIFNR = l.LIFNR
WHERE
h.MANDT = '<MANDT>'
AND h.BUDAT BETWEEN '<DATE_FROM>' AND '<DATE_TO>'
AND l.BWART IN ('101','131')
-- AND l.WERKS = '<WERKS>'
-- AND l.MATNR = '<MATNR>'
ORDER BY h.BUDAT DESC, h.MBLNR, l.ZEILE;Tables Used by This Transaction
How these tables connect — join details in the list below.
R read · W write · R/W read + write
Primary tables
Secondary tables
- LFA1Vendor Master (General Section)Read/write accessmaster
- MAKTMaterial DescriptionsRead/write accesstext
- MARAGeneral Material DataRead/write accessmaster
- MSEGDocument Segment: MaterialRead/write accesstransactionS/4HANA status: Replaced · Compat View
- T001LStorage LocationsRead/write accessconfig
- T001WPlants/BranchesRead/write accessconfig