Skip to content
SAP Reference

CO15

CreateS/4HANA status: Active

Enter Confirmation (Order)

Boilerplate SQL

Databricks SQL

Starting 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
-- ============================================================
-- T-Code : CO15 Enter Confirmation (Order)
-- Purpose: Confirm final GR on a production order; may backflush components and post material documents
-- Grain  : One row per confirmation with optional material-document enrichment
-- Tables : AFRU, MSEG, MKPF, MAKT, T001W
-- Notes  : CO15 writes AFRU + (on backflush) MKPF/MSEG. AFRU carries WABLNR (material-document number) + MYEAR (material-document year), a purpose-built 1:1 link to the specific goods movement created by that confirmation — do not bridge on AUFNR + posting date alone, which fans out across every movement for the order.
-- ============================================================
SELECT
  -- Keys
  a.MANDT   AS "Client",
  a.RUECK   AS "Confirmation Number",
  a.AUFNR   AS "Order Number",
  a.VORNR   AS "Operation Number",
  l.MBLNR   AS "Material Document",
  l.MJAHR   AS "Material Doc Year",
  l.ZEILE   AS "Material Doc Item",

  -- Descriptive text
  mt.MAKTX  AS "Material Description",

  -- Quantities + UOM (paired)
  a.LMNGA   AS "Yield",
  a.XMNGA   AS "Scrap",
  a.MEINH   AS "Confirmation UoM",
  l.MENGE   AS "Movement Quantity",
  l.MEINS   AS "Movement UoM",

  -- Dates
  a.BUDAT   AS "Confirmation Posting Date",
  h.BUDAT   AS "Material Doc Posting Date",
  a.ISDD    AS "Actual Start",
  a.IEDD    AS "Actual Finish",

  -- Status / indicators
  a.STOKZ   AS "Reversal Indicator",
  l.BWART   AS "Movement Type",
  l.SHKZG   AS "Debit/Credit Indicator",

  -- Org fields
  a.WERKS   AS "Plant",
  pt.NAME1  AS "Plant Name",
  l.LGORT   AS "Storage Location",

  -- Master data enrichment
  l.MATNR   AS "Material Number",
  a.AUFPL   AS "Routing Number",
  a.APLZL   AS "Operation General Counter",
  a.ERNAM   AS "Entered By"
FROM <catalog>.<schema>.afru a
LEFT JOIN <catalog>.<schema>.mseg l
  ON  l.MANDT = a.MANDT
  AND l.MBLNR = a.WABLNR
  AND l.MJAHR = a.MYEAR
LEFT JOIN <catalog>.<schema>.mkpf h
  ON  h.MANDT = l.MANDT
  AND h.MBLNR = l.MBLNR
  AND h.MJAHR = l.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>.t001w pt
  ON  pt.MANDT = a.MANDT
  AND pt.WERKS = a.WERKS
WHERE
  a.MANDT = '<MANDT>'
  AND a.AUFNR = '<AUFNR>'
  AND a.STOKZ = ''
ORDER BY a.BUDAT DESC, a.RUECK, l.ZEILE;

Tables Used by This Transaction

How these tables connect. Nodes are clickable.