Sub topic 9
Client, plant, and storage location levels in material master data
This chapter assumes you know what a material master is, can read a simple Open SQL SELECT, and have met the client, plant, and storage location from earlier chapters. It shows how each organisational unit maps to a level at which material data and stock are stored.
One material, several levels
A material is created once, but its data is not kept in one place. SAP splits the material master into levels. Each level answers a different question and is keyed by an organisational unit.
| Level | Key | What is stored | Example table |
|---|---|---|---|
| Client (general data) | MATNR | Description, base unit of measure, material group | MARA |
| Plant | MATNR + WERKS | MRP settings, procurement type, planning data | MARC |
| Storage location | MATNR + WERKS + LGORT | Quantities, such as unrestricted-use stock | MARD |
| Valuation area | MATNR + BWKEY | Price, valuation class, total valued stock | MBEW |
The valuation row is usually keyed by plant, because the valuation area is usually equal to the plant. The previous chapter on valuation areas covers that link.
Why the levels exist
Data sits at the lowest level where it can legitimately differ.
- The base unit of measure is the same everywhere in the client. It is stored once at client level.
- Safety stock or lot size can differ between a plant in Hamburg and one in Dallas. It is stored per plant.
- Quantities are physical. Ten pieces are in a particular place, so stock is stored per storage location.
A consequence follows from this. A material must be extended to a plant before you can post stock there, and it must be extended to a storage location before you can hold stock in that location. "Extending" means creating the lower-level record.
Reading the levels in a query
The query below reads unrestricted-use stock (LABST) from MARD, the level where quantities are held. Each row is one material in one storage location of the plant.
DATA lv_werks TYPE werks_d VALUE '1000'.
SELECT matnr, werks, lgort, labst
FROM mard
WHERE werks = @lv_werks
INTO TABLE @DATA(lt_stock).The result has one row per combination of matnr, werks, and lgort. To get the total stock of a material in the plant, add up the rows for its storage locations. MARD is also the table that tells you a storage location is unique only within its plant. The same lgort value, such as 0001, can occur in many plants. The key is the combination.
Aggregating upward
Because quantities live at the lowest level, higher-level views are sums. This query totals stock per material for the plant.
DATA lv_werks TYPE werks_d VALUE '1000'.
SELECT matnr, SUM( labst ) AS total_labst
FROM mard
WHERE werks = @lv_werks
GROUP BY matnr
INTO TABLE @DATA(lt_totals).Stock figures at plant level are not stored separately in this table. They are calculated from the storage location rows.
Common errors
- Joining on
werksonly. If you joinMARDto a table on plant alone, you multiply rows by the number of storage locations. Includelgortwhen the other table is also at storage location level. - Assuming every plant has the same data. A material can exist in plant 1000 and not in plant 2000. A missing
MARCrow means the material is not extended to that plant. - Treating a storage location key as global. Filtering
MARDbylgortalone mixes stock from several plants. - Looking for quantities in
MARA. It holds only client-level data. Stock figures are not there.
Summary of the model
Client data is shared by all plants. Plant data describes how a site plans and procures the material. Storage location data records where the quantity physically sits. When you decide where a requirement belongs, ask whether it is the same for the whole client, different per site, or tied to a physical place.
Exercise
A company wants a different reorder point for the same material in two plants, and wants to know how many units are in the warehouse area 0002 of plant 1000. At which levels is each piece of information stored, and which table holds the quantity?
Show answer
The reorder point is plant-level data, so it is stored per material and plant (table MARC). The quantity in warehouse area 0002 is storage location data, stored per material, plant, and storage location in table MARD, in the field LABST for unrestricted-use stock.
Exercise
Why does a query that selects from MARD with WHERE lgort = '0001' and no plant condition return misleading results?
Show answer
A storage location is unique only within its plant, so the key 0001 can exist in many plants. Without a plant condition the query mixes stock from all of them.