Closing stock, standard cost and actual cost by company code: one HANA SQL query in DB02
Give it a company code and get the closing stock quantity, the standard cost value and the actual cost value for every material — per period, in one result set. Runs in DB02 → Diagnostics → SQL Editor as plain HANA SQL, not an ABAP report. Amounts come from the Material Ledger period tables. Verified on an S/4HANA sandbox: client 100, company code CC10, fiscal year 2026 period 007. 0. Before you start — valuation area wiring, and whether the physical table is still readable Case Company code ↔ valuation area ↔ plant — T001K / T001W What it does The starting point for pulling material data by company code. T001K links valuation area (BWKEY) to company code (BUKRS); T001W links plant (WERKS) to valuation area. MLBWA='X' means the Material Ledger is active for that valuation area. Watch out At plant-level valuation BWKEY = WERKS, so the join is 1:1. At company-code-level valuation one valuation area carries several plants and the join multiplies rows. Result 1 row (PT10) SEL...