SAP Reference
MB52
Report S/4HANA status: ActiveList of Warehouse Stocks on Hand
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
5 parameters not filled: <catalog>, <schema>, <MANDT>, <WERKS>, <MATNR>
-- ============================================================
-- T-Code : MB52 List of Warehouse Stocks on Hand
-- Purpose: Current warehouse stocks across plant / storage location / batch / sales-order dimensions
-- Grain : One row per material / plant / storage-location; batch and sales-order stock are pre-aggregated to that same grain
-- Tables : MARD, MCHB, MSKA, MAKT, MARA, T001W, T001L
-- Notes : On S/4HANA, MARD / MCHB / MSKA are served from MATDOC via CDS compatibility views — totals may shift mid-query since the three tables aren't read atomically. Reconcile against a period close if financials need to tie. MCHB is keyed at batch grain and MSKA at sales-order-item grain — joining either directly on material/plant/storage-location alone fans out to a batch-by-sales-order cross product and duplicates the MARD quantities, so both are pre-summed to material/plant/storage-location before joining; per-batch and per-sales-order detail is not shown here (see MMBE for that breakdown).
-- ============================================================
SELECT
-- Keys
m.MANDT AS "Client",
m.MATNR AS "Material Number",
m.WERKS AS "Plant",
m.LGORT AS "Storage Location",
-- Descriptive text
mt.MAKTX AS "Material Description",
-- Quantities + UOM (paired)
m.LABST AS "Unrestricted Stock",
m.INSME AS "Quality Inspection Stock",
m.SPEME AS "Blocked Stock",
m.EINME AS "Restricted Stock",
m.UMLME AS "Stock In Transfer",
ma.MEINS AS "Base Unit of Measure",
-- Status / indicators
m.LVORM AS "Deletion Flag",
m.KZILL AS "Unrestricted-Use Stock Ind.",
-- Org fields
pt.NAME1 AS "Plant Name",
sl.LGOBE AS "Storage Location Name",
-- Master data enrichment
ma.MTART AS "Material Type",
ma.MATKL AS "Material Group",
b.CLABS AS "Batch Unrestricted (Aggregated)",
b.CINSM AS "Batch Quality Inspection (Aggregated)",
b.CSPEM AS "Batch Blocked (Aggregated)",
s.KALAB AS "Sales Order Stock (Aggregated)"
FROM <catalog>.<schema>.mard m
LEFT JOIN (
SELECT
MANDT, MATNR, WERKS, LGORT,
SUM(CLABS) AS CLABS,
SUM(CINSM) AS CINSM,
SUM(CSPEM) AS CSPEM
FROM <catalog>.<schema>.mchb
GROUP BY MANDT, MATNR, WERKS, LGORT
) b
ON b.MANDT = m.MANDT
AND b.MATNR = m.MATNR
AND b.WERKS = m.WERKS
AND b.LGORT = m.LGORT
LEFT JOIN (
SELECT
MANDT, MATNR, WERKS, LGORT,
SUM(KALAB) AS KALAB
FROM <catalog>.<schema>.mska
GROUP BY MANDT, MATNR, WERKS, LGORT
) s
ON s.MANDT = m.MANDT
AND s.MATNR = m.MATNR
AND s.WERKS = m.WERKS
AND s.LGORT = m.LGORT
LEFT JOIN <catalog>.<schema>.makt mt
ON mt.MANDT = m.MANDT
AND mt.MATNR = m.MATNR
AND mt.SPRAS = 'E'
LEFT JOIN <catalog>.<schema>.mara ma
ON ma.MANDT = m.MANDT
AND ma.MATNR = m.MATNR
LEFT JOIN <catalog>.<schema>.t001w pt
ON pt.MANDT = m.MANDT
AND pt.WERKS = m.WERKS
LEFT JOIN <catalog>.<schema>.t001l sl
ON sl.MANDT = m.MANDT
AND sl.WERKS = m.WERKS
AND sl.LGORT = m.LGORT
WHERE
m.MANDT = '<MANDT>'
AND m.WERKS = '<WERKS>'
AND m.MATNR = '<MATNR>'
ORDER BY m.WERKS, m.MATNR, m.LGORT;Tables Used by This Transaction
R read · W write · R/W read + write