Sub topic 2
Where data lives: organizational levels
This chapter assumes you can navigate SAP GUI and know what a company code and a plant are. It also assumes you have a general picture of procurement, production, sales, and inventory. The ABAP at the end is optional reading.
Why levels exist
A company buys, stores, and sells the same material in many places. Some facts about the material are the same everywhere. Other facts depend on the plant, the warehouse, or the sales organization. The material master stores each fact once, at the most general level where it is still true.
This avoids duplicates and keeps data consistent. If the weight of a bolt changes, you change it once. If the MRP planner for the bolt differs between two plants, each plant keeps its own value.
An organizational level is a unit in the enterprise structure that owns a block of material data. The levels are:
- Client
- Plant
- Storage location
- Sales organization combined with distribution channel
- Valuation area
- Warehouse number and storage type, if Warehouse Management is used
Company code is also part of the enterprise structure, but it is not a level at which material data is stored.
The levels in detail
Client
The client is the highest level. Data stored here is valid for every plant, sales organization, and company code in the client. Typical examples are the material number, material type, base unit of measure, weights, and material descriptions. This data lives in the general data table MARA and the description table MAKT. The Basic Data views edit it.
Plant
A plant is a production site, a distribution center, or a group of storage locations, depending on how your company defines it. Plant data covers planning and procurement parameters that differ by location. Examples are MRP type, procurement type, reorder point, lot-size procedure, and the purchasing group. Plant data lives in MARC. A material must exist at a plant before you can plan it, buy it for that plant, or hold stock of it there.
Storage location
A storage location is a place within a plant where stock is physically kept. It holds data such as the storage bin and stock quantities. Storage location data lives in MARD. One plant can have several storage locations, and each material can be extended to some of them and not others.
Sales organization and distribution channel
Sales data is stored per combination of sales organization and distribution channel. Examples are the delivery plant, the sales unit, and the material pricing group. This data lives in MVKE. The same material can have different sales data for a direct-sales channel and a wholesale channel.
Valuation area
The valuation area is the level at which the material is valued. It determines how stock is priced and which accounts are posted. In S/4HANA the valuation area is always the plant. Earlier SAP ERP releases also allowed valuation at company-code level, but S/4HANA does not. Valuation data lives in MBEW. The key field is the valuation area (BWKEY), and the valuation type (BWTAR) is blank unless split valuation is used.
Warehouse number and storage type
If you use Warehouse Management, data such as picking and putaway strategies is stored per warehouse number (MLGN) and per storage type within the warehouse (MLGT). The Warehouse Management views edit this data. A later chapter covers them.
How the levels relate
The levels form a hierarchy. A plant belongs to exactly one company code, and a storage location belongs to exactly one plant. Sales organizations are a separate branch of the structure, linked to plants through assignments such as the delivery plant.
Data by level
| Level | Example data | Table | Key |
|---|---|---|---|
| Client | Material type, base unit, weight, description | MARA, MAKT | MATNR (and SPRAS for MAKT) |
| Plant | MRP type, procurement type, purchasing group | MARC | MATNR, WERKS |
| Storage location | Stock quantity, storage bin | MARD | MATNR, WERKS, LGORT |
| Sales org and channel | Delivery plant, sales unit | MVKE | MATNR, VKORG, VTWEG |
| Valuation area | Price control, standard or moving average price | MBEW | MATNR, BWKEY, BWTAR |
| Warehouse number | Picking and putaway data | MLGN | MATNR, LGNUM |
Consequences for daily work
Extension follows the levels
Creating a material for the first time writes the client data. To use the material in another plant, you extend it, which adds a new plant record and the matching valuation record. To sell it through another channel, you add a sales record. The next chapters cover the transactions. For now, remember that "extending" means adding a row at a lower level.
A lower level cannot exist without the level above it
You cannot create a MARC record without a MARA record. You cannot create a MARD record unless the plant record exists. The system enforces this. A common error message when extending is that the material does not exist at the plant, which means the plant-level record is missing.
The same field name can mean different things
Some attributes exist at more than one level. For example, a purchasing group is a plant attribute, while the base unit of measure is a client attribute. When a value looks wrong, first check which level you are looking at. Fixing it at the wrong level changes nothing for the process that reads the other one.
Valuation follows the plant
Because the valuation area is the plant in S/4HANA, every plant that holds valued stock needs its own valuation record. Price control, standard price, and moving average price are therefore set per plant. Two plants of the same company code can carry different prices for the same material.
Reading across levels with ABAP SQL
This report joins the client level (MARA), the plant level (MARC), and the storage-location level (MARD) for one material. It then adds the valuation record (MBEW), which is matched to the plant through the valuation area.
REPORT zdemo_matorg.
PARAMETERS p_matnr TYPE mara-matnr OBLIGATORY.
START-OF-SELECTION.
SELECT mara~matnr,
marc~werks,
mard~lgort,
mard~labst,
mbew~vprsv,
mbew~verpr,
mbew~stprs
FROM mara
INNER JOIN marc ON marc~matnr = mara~matnr
INNER JOIN mard ON mard~matnr = marc~matnr
AND mard~werks = marc~werks
INNER JOIN mbew ON mbew~matnr = marc~matnr
AND mbew~bwkey = marc~werks
AND mbew~bwtar = @space
WHERE mara~matnr = @p_matnr
INTO TABLE @DATA(lt_rows).
IF lt_rows IS INITIAL.
WRITE / 'No plant and storage location data found.'.
ENDIF.
LOOP AT lt_rows INTO DATA(ls_row).
WRITE: / ls_row-matnr, ls_row-werks, ls_row-lgort, ls_row-labst,
ls_row-vprsv, ls_row-verpr, ls_row-stprs.
ENDLOOP.The parameter uses the data element of MARA-MATNR, so the selection screen applies the material number conversion exit for you. If you pass a hard-coded value in a program, convert it first, because numeric material numbers are stored with leading zeros.
The inner joins return one row per material, plant, and storage location. A material with a plant record but no storage location record does not appear. Use a left outer join from MARC to MARD if you also need plants without storage locations.
Common errors
- Looking for plant data in MARA. MARA holds only client-level fields. Plant fields such as the MRP type are in MARC.
- Forgetting the valuation type in MBEW joins. Without a condition on BWTAR, a material with split valuation returns several rows per plant.
- Assuming valuation at company-code level in S/4HANA. This option was removed. The valuation area is the plant.
- Extending to a storage location before the plant. The plant record must come first.
Exercise
A material exists in plant 1010 and plant 2020, both in company code 1000. A planner changes the reorder point in plant 1010. Does plant 2020 see the change? In which table is the field stored, and why?
Show answer
No. The reorder point is plant-level data, stored in MARC with the key MATNR and WERKS. Each plant has its own MARC row, so the change affects only plant 1010. Client-level data such as the base unit in MARA would change for both plants because it exists once per client.
Exercise
Why does the join in the example report return no rows for a material that has a MARC record but no MARD record?
Show answer
The report uses INNER JOIN from MARC to MARD, and an inner join keeps only rows with a match on both sides. With no storage-location row, there is no match. A LEFT OUTER JOIN from MARC to MARD would keep the plant row.