Sub topic 9
Inventory and warehouse management
This chapter assumes you know the procurement and sales documents from the earlier chapters (purchase order, delivery, billing) and the organizational units plant and storage location. It also assumes you can read a simple SQL join. It covers how S/4HANA records stock, how stock movements create accounting postings, and where warehouse management starts.
What inventory management is responsible for
Inventory Management (IM) is the part of Materials Management (MM) that answers three questions: what stock exists, where it is, and what it is worth. It does not plan production or decide what to buy. It records every change to stock as a goods movement and keeps stock quantities and stock values consistent.
Two levels of detail exist:
- Inventory Management tracks stock by material, plant, storage location, and optionally batch or special stock. It knows quantities and values, but not which shelf holds the goods.
- Warehouse management tracks stock inside a storage location by bin and handling unit, and it controls the physical work: putaway, picking, and packing.
You can run a plant with IM alone. Warehouse management is added when the physical process needs to be controlled and not only recorded.
Stock is defined by organizational levels
Stock quantities are not kept on the material itself. They are kept per combination of organizational units, and the material master has matching views.
| Level | Material master data | Typical stock information |
|---|---|---|
| Client | General data | None |
| Plant | Plant data | Valuation, planning, plant-level totals |
| Storage location | Storage location data | Quantity per physical or logical location |
| Batch or special stock | Batch data | Quantity per batch, per customer or project |
Within one storage location, stock is also split by stock type:
- Unrestricted-use stock can be used freely.
- Quality inspection stock is held until a check is complete.
- Blocked stock cannot be used, for example because of damage.
Moving goods between these types is itself a goods movement. A movement from quality inspection to unrestricted use changes no total and no value, but it still creates a document.
Goods movements and movement types
A goods movement is any posting that changes stock. Each movement has a movement type, a three-digit code that tells the system which stock to change, which accounts to post to, and which fields are required.
| Movement type | Meaning | Typical trigger |
|---|---|---|
| 101 | Goods receipt for a purchase order | Procurement |
| 122 | Return delivery to a supplier | Procurement |
| 261 | Goods issue for a production order | Manufacturing |
| 311 | Transfer between storage locations | Internal |
| 301 | Transfer between plants | Internal |
| 551 | Scrapping | Internal |
| 601 | Goods issue for an outbound delivery | Sales |
| 701 / 702 | Inventory difference, gain or loss | Physical inventory |
Reversals use a different movement type, usually the original number plus one. For example, 102 reverses 101. They create a new document and do not delete the original. This keeps the audit trail intact.
Each posting creates a material document, with a header (posting date, user) and one item per material. In S/4HANA the data lives in the table MATDOC. The classic tables MKPF (header) and MSEG (item) still exist as compatibility views, so older reports and code keep working. Stock quantities are derived from the document data and no longer maintained as many separately updated totals. This is a simplification compared with older SAP releases.
How a goods movement reaches Finance
Most goods movements are valuated. When a document is posted for a valuated material, the system also creates an accounting document in the same transaction. This is how Inventory connects to Finance and the Universal Journal.
The accounts are found automatically through account determination. The movement type, the valuation class of the material, and the chart of accounts select the accounts. For a goods receipt against a purchase order:
- Debit the inventory account (transaction key BSX).
- Credit the goods receipt/invoice receipt clearing account, known as GR/IR (transaction key WRX).
When the supplier invoice arrives, the clearing account is debited and the supplier account is credited. For a goods issue to a customer delivery, the cost of goods sold account is debited and the inventory account is credited.
Valuation: standard price or moving average
The material master holds a price control indicator for each plant:
- Standard price (S): Stock is valued at a fixed price. Differences between the standard price and the actual price are posted as price differences.
- Moving average price (V): The price is recalculated after each receipt as total stock value divided by total quantity.
In S/4HANA the Material Ledger is always active. It keeps valuation per material and can track actual costs and multiple currencies. The valuation data is stored with the Universal Journal, so inventory value reconciles with the general ledger without separate reconciliation.
Reading goods movements with a query
The next report sums quantities per movement type for one plant and year. It reads the compatibility views MKPF and MSEG, which are stable and widely used. The debit/credit indicator SHKZG shows direction: S increases stock and H decreases it.
REPORT z_movements_by_type.
SELECT mseg~bwart, mseg~shkzg, mseg~meins,
SUM( mseg~menge ) AS quantity
FROM mkpf
INNER JOIN mseg ON mseg~mblnr = mkpf~mblnr
AND mseg~mjahr = mkpf~mjahr
WHERE mseg~werks = '1010'
AND mkpf~budat BETWEEN '20240101' AND '20241231'
GROUP BY mseg~bwart, mseg~shkzg, mseg~meins
ORDER BY mseg~bwart
INTO TABLE @DATA(movements).
cl_demo_output=>display( movements ).Because the sign is carried by SHKZG, a plain sum of MENGE across both directions would be wrong. Group by the indicator, as here, or apply the sign before adding.
Physical inventory
Book stock and physical stock drift apart through theft, damage, and posting errors. Physical inventory corrects this in three steps:
- Create an inventory document for a set of materials and bins, optionally blocking posting while counting.
- Enter the counted quantities.
- Post the differences, which creates movement types 701 or 702 and a matching accounting document.
Cycle counting spreads this over the year, with fast-moving materials counted more often.
From inventory management to warehouse management
Inventory Management stops at the storage location. When a storage location is a large warehouse with many bins, the system needs finer control. S/4HANA offers these options:
- Stock Room Management is a light option for simple stores. It tracks bins as a storage location attribute. It is the typical choice in the cloud public edition when no complex warehouse process exists.
- Embedded Extended Warehouse Management (EWM) runs inside the S/4HANA system and uses the same master data. It is the current strategic warehouse application.
- Decentralized EWM runs on a separate system and connects to one or more S/4HANA systems.
- Classic Warehouse Management (WM) from older releases is in the compatibility scope of S/4HANA. Check the current SAP Note on the simplification list before building anything new on it.
EWM adds its own structure under the plant and storage location: a warehouse number, storage types (such as a high-rack area), storage sections, and storage bins. It works with warehouse tasks (a single movement from one bin to another), warehouse orders (a group of tasks given to a worker), and handling units (a pallet or box with its contents).
The warehouse process follows the logistics documents. An inbound delivery creates the putaway work, and an outbound delivery creates the picking work. Posting the goods receipt or goods issue in the warehouse updates Inventory Management and Finance through the usual material document.
Common errors
- Negative stock. Posting an issue before the receipt is allowed only if negative stock is enabled for the plant. If so, values are corrected on the later receipt, which can cause price differences.
- Stuck GR/IR balance. A goods receipt without a matching invoice leaves a balance in the clearing account. Clear it with the periodic GR/IR clearing.
- Wrong period. Posting in a closed period fails. Posting date and material period must be open.
- Missing account determination. A new valuation class without account assignments raises an error on the first posting.
Exercise
A goods receipt (movement type 101) of 10 pieces valued at 50 EUR each is posted for a purchase order. Which accounts are debited and credited, and what happens when the supplier invoice is later posted?
Show answer
The goods receipt debits the inventory account (BSX) by 500 EUR and credits the GR/IR clearing account (WRX) by 500 EUR. When the invoice is posted, GR/IR is debited and the supplier (payables) account is credited, which clears the GR/IR balance.
Exercise
Why does the sample query group by SHKZG, and what would be wrong with summing MENGE only per movement type?
Show answer
MENGE is always stored as a positive number. SHKZG shows whether the item increases stock (S) or decreases it (H). Summing MENGE without regard to SHKZG adds receipts and issues together and gives a wrong total. Grouping by SHKZG, or applying the sign before summing, gives the correct direction for each quantity.