Sub topic 7
The storage location: where stock is physically kept
This chapter assumes you know what a client, company code, and plant are, and that a plant belongs to exactly one company code. You should also be comfortable reading a simple relational table with a composite key and a basic SELECT statement.
What a storage location is
A storage location is the lowest organisational unit used for inventory in SAP ERP. It marks a place inside a plant where stock is physically kept, such as a raw material warehouse, a finished goods area, or a quarantine room.
A storage location is not a legal or financial unit. It has no balance sheet and no address of its own. Its job is to answer one question: where inside the plant is this material?
Position in the hierarchy
Every storage location belongs to exactly one plant. A plant can have many storage locations.
Because the plant sits above it, a storage location inherits the plant's company code. You do not assign a storage location to a company code directly.
The key is plant plus storage location
The storage location key is a four-character code, for example 0001. That code is unique only within its plant. Plant 1000 and plant 2000 can both have a storage location 0001, and they are two different places.
So the full identity of a storage location is the pair of plant and storage location. In table T001L the key is client, WERKS (plant), and LGORT (storage location).
DATA lv_werks TYPE werks_d VALUE '1000'.
SELECT lgort, lgobe
FROM t001l
WHERE werks = @lv_werks
INTO TABLE @DATA(lt_storage_locations).This query lists the storage locations of plant 1000. LGORT is the key and LGOBE is the description. The WHERE condition on WERKS is needed. Without it you would get every storage location of every plant, and the same LGORT value could appear many times.
Where stock quantities are held
Quantities are kept at storage location level. Table MARD holds one row per material, plant, and storage location. The field LABST is the unrestricted-use stock.
DATA lv_werks TYPE werks_d VALUE '1000'.
SELECT matnr, werks, lgort, labst
FROM mard
WHERE werks = @lv_werks
INTO TABLE @DATA(lt_stock).Each row says how much of a material is available in one storage location of the plant. Adding up LABST over all storage locations of a plant gives the plant's unrestricted stock for that material.
Valuation is different. The value of stock is kept at plant level (more precisely, at valuation area level, covered in a later chapter). A storage location holds quantities, not a separate price. Moving stock between two storage locations of the same plant therefore changes the quantity in each, but it does not change the total inventory value.
What a storage location is used for
- Separating stock by physical area, such as high-bay racking and a returns area.
- Separating stock by purpose, such as stock reserved for production and stock for sales.
- Allowing material master data to be maintained only for the locations where a material is actually stored.
- Letting a goods movement name the exact place a quantity leaves or enters.
Common errors
- Treating
LGORTas globally unique. A query or a join onLGORTalone returns rows from several plants. Always includeWERKS. - Looking for stock value in MARD. MARD is mainly about quantity. Value is held at valuation level.
- Creating a storage location for a material in the wrong plant. A storage location only exists for materials that have a plant view, and stock is booked against that plant.
Exercise
Plants 1000 and 2000 both have a storage location 0001. A colleague writes a query on table MARD that filters only on LGORT = '0001'. What does the query return, and how do you fix it?
Show answer
It returns stock rows from both plants, because the storage location key is unique only within a plant. Add a condition on WERKS (for example WERKS = '1000') so the plant and storage location pair identifies one place.