SAP Business One Units of Measure: Configure UoM Groups and Audit Conversions with SQL

Publications

SAP Business One Units of Measure: Configure UoM Groups and Audit Conversions with SQL

Hector Pincheira

Hector Pincheira

CIO | CTO
Digital Strategy & Technology Innovation

items

A distributor received 480 boxes of a supply. The supplier invoiced boxes, the warehouse worker counted boxes, and the system recorded 480 units. Six weeks later, when the physical inventory showed a difference of 5,280 units, nobody understood what had happened. There was no theft or counting error: there was a misconfigured conversion factor. The SAP Business One Units of Measure They are the quietest piece of the article master and, at the same time, the one that destroys trust in your figures the fastest.

This tutorial covers the complete cycle: how unit of measure groups are set up, how they propagate to purchasing, sales, and inventory, and how to audit with SQL whether your conversions are healthy. By the end, you will have five queries ready to run in SQL Server and SAP HANA.

SAP Business One Units of Measure - warehouse with pallets and boxes in racks
The same item travels as a pallet, box, and unit. The ERP must know how to translate between all three.

The real problem: every area speaks in its own unit

Purchasing negotiates in pallets. Warehouse receives in boxes. Sales quotes in units. Production consumes in kilos. Each department is right within its own process, and yet inventory is singular. Therefore, someone has to translate. When that translation lives in the warehouse manager's head and not in the ERP, the company operates with a structural risk that no one has quantified.

In practice, the symptom does not appear as a system error. It appears as a margin that doesn't add up, an inexplicable stockout, or a unit cost that jumps from month to month. Furthermore, the usual diagnosis points in the wrong direction: blame is placed on the physical count, the supplier, or the salesperson. However, the root cause is usually found in three tables of the master data that almost no one reviews.

SAP Business One Units of Measure: The Three-Table Architecture

Before touching any configuration, it is advisable to understand the model. SAP Business One resolves conversions with three chained objects, and each fulfills a different function.

  • OUOM — the units catalog. Each physical unit exists only once: Unit, Box, Pallet, Kilo, Liter. The key field is UomEntry.
  • OUGP — the unit groups. A group defines a base unit (Base UoM) and group all the units related to it. For example, the Beverages-1L group.
  • UGP1 — the conversion detail. Here lives the factor: how many base units are equivalent to an alternative unit, through the fields Base Quantity and AltQty.

The article connects to this model through OITM.UgpEntry. In addition, define three default units: inventory (IUoMEntry), purchases (PUoMEntry) and sales (SUoMEntryFinally, each document line freezes the factor applied in the field NumPerMsr, and saves the converted amount in Inventory Qty. That freezing is the key to everything: if you change the master factor later, historical documents keep the old factor.

In other words: a belated correction does not repair the past. It only prevents the error from continuing to grow. That is why SQL auditing is not optional.

Prerequisites before touching anything

This procedure modifies master data that affects inventory valuation and accounting. Consequently, do not execute it live without meeting these conditions.

  1. Authorization of Item master data and of Inventory definitions in General Authorizations.
  2. Verified production database backup, not just scheduled.
  3. Test environment with a recent copy to validate the factors before applying them.
  4. Written agreement with Warehouse, Purchasing, and Sales regarding the base unit for each product family. This point seems administrative, but it is the one that sinks the most projects.
  5. Read-only access to the database to execute audit queries. Never use the application user to query.

Critical warning: An item that has already recorded inventory movements does not allow freely changing its unit of measure group. SAP blocks the change precisely to protect valuation. Therefore, plan the configuration before uploading the master data, not after.

Step-by-step tutorial: set up a unit of measure group

We will work with a concrete and recognizable case: an item that is purchased by the pallet, stored and moved by the case, and sold by the unit. The base unit will be the sales unit, because it is the smallest and allows for the greatest cost granularity.

SAP Business One Units of Measure - box with internal divisions representing the conversion factor
The conversion factor is a physical question rather than a technical one: how many units actually fit in a box.

Step 1: define the units in the catalog

Navigate to Management > Definitions > Inventory > Units of Measure. Create each unit with a short and stable code: UN, CAJ, PAL, KG, LT. In addition, complete the dimensions and weight when the item warrants it, because this data later feeds the freight calculation and warehouse occupancy.

A pain-saving tip: do not create product-specific units, like BOX-12 or BOX-24. The quantity belongs in the group factor, not in the unit name. Otherwise, you'll end up with forty units of measure and no rhyme or reason.

Step 2: create the group and load the factors

Go Management > Definitions > Inventory > Unit of Measurement Groups. Define the group code, description, and base unit. Then, in the detail section, add each alternative unit with its equivalence.

For our example, the group would look like this: base unit UN; the box is defined as 1 CAJ equal to 12 UN; the pallet is defined as 1 PAL equal to 480 UN. SAP stores this relationship in UGP1 using two fields, AltQty and Base Quantity. The effective factor is BaseQty / AltQty. Therefore, if you need to express that 3 boxes equal 40 units, you can set AltQty to 3 and BaseQty to 40 without forcing decimals.

That detail matters more than it seems. When the factor is not an integer, rounding in the master data generates a cascading difference that accumulates document by document until it becomes visible at closing.

Step 3: Assign the group to the article

Open the item master, tab Inventory data, and select the group in the field Group of units of measurement. If the field shows the value Manual, the article operates in legacy mode: SAP does not apply any automatic conversion and only uses the flat factors NumInBuy and Number in Sale. In the database, that state is identified by OITM.UgpEntry = -1, and it is the main source of silent discrepancies.

Step 4: Define the default units for each process

In the tabs Purchase data and Sales data Select the default unit for each flow. This way, when the buyer enters an order, SAP will propose pallet; when the salesperson quotes, it will propose unit; and inventory will continue to be accounted for in the base unit. Consequently, each user works in their own language and the system translates automatically.

Step 5: upload prices in the correct unit

This is the step that concentrates the most errors. SAP Business One price lists are expressed per list unit, not always per base unit. Therefore, if the unit selling price is 1,200 and someone enters it on a line for boxes, the system will sell twelve units for the price of one. In addition, the margin will appear negative without any prior warning. Query 4 of this tutorial is designed specifically to catch that case.

Five SQL queries to audit your conversions

Each query includes its version for SQL Server and for SAP HANA. Execute them in that order: first you understand how it is configured, then you find what is broken, and finally you quantify the damage.

X-ray of groups and factors

Start by viewing the entire model on a single screen. This query shows each group, its base unit, each alternative unit, the effective factor, and how many items depend on that configuration.

SQL Server

-- X-ray of unit of measure groups and conversion factors
SELECT
    T0.UgpCode                AS GroupCode,
    T0.UgpName                AS Description,
    T2.UomCode                AS BaseUnit,
    T3.UomCode                AS AlternateUnit,
    T1.AltQty                 AS AlternateQuantity,
    T1.BaseQty                AS BaseQuantity,
    CAST(T1.BaseQty / NULLIF(T1.AltQty, 0) AS DECIMAL(19,6)) AS EffectiveFactor,
    (SELECT COUNT(*) FROM OITM I WHERE I.UgpEntry = T0.UgpEntry) AS AssignedItems
FROM OUGP T0
INNER JOIN UGP1 T1 ON T0.UgpEntry = T1.UgpEntry
INNER JOIN OUOM T2 ON T0.BaseUom  = T2.UomEntry
INNER JOIN OUOM T3 ON T1.UomEntry = T3.UomEntry
ORDER BY T0.UgpCode, EffectiveFactor;

SAP HANA

-- X-ray of unit of measure groups and conversion factors
SELECT
    T0."UgpCode"              AS "Group",
    T0."UgpName"              AS "Description",
    T2."UomCode"              AS "BaseUnit",
    T3."UomCode"              AS "AlternateUnit",
    T1."AltQty"               AS "AlternateQuantity",
    T1."BaseQty"              AS "BaseQuantity",
    T1."BaseQty" / T1."AltQty" AS "EffectiveFactor",
    (SELECT COUNT(*) FROM OITM I WHERE I."UgpEntry" = T0."UgpEntry") AS "AssignedItems"
FROM OUGP T0
INNER JOIN UGP1 T1 ON T0."UgpEntry" = T1."UgpEntry"
INNER JOIN OUOM T2 ON T0."BaseUom"  = T2."UomEntry"
INNER JOIN OUOM T3 ON T1."UomEntry" = T3."UomEntry"
WHERE T1."AltQty"  0
ORDER BY T0."UgpCode", "EffectiveFactor";

Read the result with a critical eye. If a group has zero articles assigned, it is redundant. If a factor is not an integer and the product is discrete, there is a capture error. If two different groups describe the same physical reality, you have master data duplication.

Query 2: manual mode items with valued stock

Items without a unit group are the master user's silent time bomb. They don't fail, they don't trigger alerts, and they don't show up in any standard report. However, any document using a unit other than the inventory unit relies entirely on the user typing it correctly. This query exposes them and ranks them by money at risk.

SQL Server

-- Items without UoM group (Manual mode) with valued inventory
SELECT
    T0.ItemCode,
    T0.ItemName,
    T0.InvntryUom             AS InventoryUomText,
    T0.NumInBuy               AS PurchaseFactorFlat,
    T0.NumInSale              AS SalesFactorFlat,
    T0.OnHand                 AS CurrentStock,
    T0.AvgPrice               AS AverageCost,
    CAST(T0.OnHand * T0.AvgPrice AS DECIMAL(19,2)) AS ValueAtRisk
FROM OITM T0
WHERE T0.InvntItem = 'Y'
  AND T0.validFor  = 'Y'
  AND ISNULL(T0.UgpEntry, -1) = -1
  AND T0.OnHand  0
ORDER BY ValueAtRisk DESC;

SAP HANA

-- Items without UoM group (Manual mode) with valued inventory
SELECT
    T0."ItemCode",
    T0."ItemName",
    T0."InvntryUom"           AS "InventoryUomText",
    T0."NumInBuy"             AS "FlatPurchaseFactor",
    T0."NumInSale"            AS "FlatSalesFactor",
    T0."OnHand"               AS "CurrentStock",
    T0."AvgPrice"             AS "AverageCost",
    T0."OnHand" * T0."AvgPrice" AS "ValueAtRisk"
FROM OITM T0
WHERE T0."InvntItem" = 'Y'
  AND T0."validFor"  = 'Y'
  AND IFNULL(T0."UgpEntry", -1) = -1
  AND T0."OnHand"  0
ORDER BY "ValueAtRisk" DESC;

The value of this query isn't technical—it's managerial. It turns an abstract configuration problem into a concrete figure that you can present to the committee. For example, if the result shows an 18% in the valued inventory, you already have the justification for the restructuring project.

Query 3: document lines with misaligned factor

This is the most important query of the article. It compares the frozen factor in each invoice line against the current factor in the master data. When both differ, it means someone changed the conversion after issuing the document, or the line was entered with a manual factor. Consequently, the deducted stock does not correspond to the physical reality.

SQL Server

-- Sales invoice lines with a conversion factor different from the master
SELECT
    T0.DocNum,
    T0.DocDate,
    T1.ItemCode,
    T1.Dscription,
    T1.UomCode,
    T1.Quantity               AS LineQuantity,
    T1.NumPerMsr              AS LineFactor,
    CAST(T4.BaseQty / NULLIF(T4.AltQty, 0) AS DECIMAL(19,6)) AS MasterFactor,
    T1.InvQty                 AS InventoryQuantity,
    CAST(T1.Quantity * (T4.BaseQty / NULLIF(T4.AltQty, 0)) - T1.InvQty AS DECIMAL(19,4)) AS UnitDifference
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry  = T1.DocEntry
INNER JOIN OITM T2 ON T1.ItemCode  = T2.ItemCode
INNER JOIN OUGP T3 ON T2.UgpEntry  = T3.UgpEntry
INNER JOIN UGP1 T4 ON T4.UgpEntry  = T3.UgpEntry
                  AND T4.UomEntry  = T1.UomEntry
WHERE T0.DocDate >= DATEADD(MONTH, -6, GETDATE())
  AND T4.AltQty  0
  AND ABS(T1.NumPerMsr - (T4.BaseQty / NULLIF(T4.AltQty, 0))) > 0.0001
ORDER BY T0.DocDate DESC;

SAP HANA

-- A/R invoice lines with a conversion factor different from the master data
SELECT
    T0."DocNum",
    T0."DocDate",
    T1."ItemCode",
    T1."Dscription",
    T1."UomCode",
    T1."Quantity"             AS "LineQuantity",
    T1."NumPerMsr"            AS "LineFactor",
    T4."BaseQty" / T4."AltQty" AS "MasterFactor",
    T1."InvQty"               AS "InventoryQuantity",
    T1."Quantity" * (T4."BaseQty" / T4."AltQty") - T1."InvQty" AS "UnitDifference"
FROM OINV T0
INNER JOIN INV1 T1 ON T0."DocEntry"  = T1."DocEntry"
INNER JOIN OITM T2 ON T1."ItemCode"  = T2."ItemCode"
INNER JOIN OUGP T3 ON T2."UgpEntry"  = T3."UgpEntry"
INNER JOIN UGP1 T4 ON T4."UgpEntry"  = T3."UgpEntry"
                  AND T4."UomEntry"  = T1."UomEntry"
WHERE T0."DocDate" >= ADD_MONTHS(CURRENT_DATE, -6)
  AND T4."AltQty"  0
  AND ABS(T1."NumPerMsr" - (T4."BaseQty" / T4."AltQty")) > 0.0001
ORDER BY T0."DocDate" DESC;

To audit purchases instead of sales, replace OINV/INV1 by OPCH/PCH1 the pore OPDN/PDN1 If you want to review goods receipts, the join logic remains identical, because all line tables share the fields. UomEntry, NumPerMsr e Inventory Qty.

SAP Business One Units of Measure - barcode reader verifying a box label
The label says box. The system must know how many units are inside, without asking anyone.

Query 4: low-cost sales due to price loaded on the wrong unit

When the unit price is applied to a line sold in boxes, the margin collapses without anyone noticing. This query calculates the actual price per base unit and compares it against the item's average cost. As a result, you get the exact list of invoices that sold below cost due to a unit of measure issue.

SQL Server

-- Low-cost sales caused by price loaded in the incorrect UoM
SELECT
    T0.DocNum,
    T0.DocDate,
    T2.CardName               AS Cliente,
    T1.ItemCode,
    T1.UomCode,
    T1.Quantity,
    T1.NumPerMsr              AS UnidadesPorLinea,
    T1.PriceBefDi             AS PrecioPorUomLinea,
    CAST(T1.PriceBefDi / NULLIF(T1.NumPerMsr, 0) AS DECIMAL(19,4)) AS PrecioPorUnidadBase,
    T3.AvgPrice               AS CostoUnitarioBase,
    T1.LineTotal
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode
INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode
WHERE T0.DocDate >= DATEADD(MONTH, -3, GETDATE())
  AND T1.NumPerMsr > 1
  AND T3.AvgPrice > 0
  AND (T1.PriceBefDi / NULLIF(T1.NumPerMsr, 0)) < T3.AvgPrice
ORDER BY T1.LineTotal DESC;

SAP HANA

-- Low-cost sales caused by price charged in the incorrect UoM
SELECT
    T0."DocNum",
    T0."DocDate",
    T2."CardName"             AS "Customer",
    T1."ItemCode",
    T1."UomCode",
    T1."Quantity",
    T1."NumPerMsr"            AS "UnitsPerLine",
    T1."PriceBefDi"           AS "PricePerLineUom",
    T1."PriceBefDi" / T1."NumPerMsr" AS "PricePerBaseUnit",
    T3."AvgPrice"             AS "BaseUnitCost",
    T1."LineTotal"
FROM OINV T0
INNER JOIN INV1 T1 ON T0."DocEntry" = T1."DocEntry"
INNER JOIN OCRD T2 ON T0."CardCode" = T2."CardCode"
INNER JOIN OITM T3 ON T1."ItemCode" = T3."ItemCode"
WHERE T0."DocDate" >= ADD_MONTHS(CURRENT_DATE, -3)
  AND T1."NumPerMsr" > 1
  AND T3."AvgPrice" > 0
  AND (T1."PriceBefDi" / T1."NumPerMsr") < T3."AvgPrice"
ORDER BY T1."LineTotal" DESC;

Query 5: exposure due to difference between purchase unit and inventory

The last query sizes the structural risk. It shows the items whose purchase unit differs from the inventory unit and orders the result by the magnitude of the factor. The greater the factor, the greater the damage of a unit error. For example, making a mistake on an item with a factor of 480 multiplies the error almost five hundred times.

SQL Server

-- Exposure by magnitude of the conversion factor in purchases
SELECT
    T0.ItemCode,
    T0.ItemName,
    T1.UgpCode                AS GroupCode,
    T2.UomCode                AS InventoryUom,
    T3.UomCode                AS PurchaseUom,
    T4.UomCode                AS SalesUom,
    CAST(T5.BaseQty / NULLIF(T5.AltQty, 0) AS DECIMAL(19,4)) AS PurchaseFactor,
    T0.OnHand,
    CAST(T0.OnHand * T0.AvgPrice AS DECIMAL(19,2)) AS InventoryValue
FROM OITM T0
INNER JOIN OUGP T1 ON T0.UgpEntry  = T1.UgpEntry
LEFT  JOIN OUOM T2 ON T0.IUoMEntry = T2.UomEntry
LEFT  JOIN OUOM T3 ON T0.PUoMEntry = T3.UomEntry
LEFT  JOIN OUOM T4 ON T0.SUoMEntry = T4.UomEntry
LEFT  JOIN UGP1 T5 ON T5.UgpEntry  = T0.UgpEntry
                  AND T5.UomEntry  = T0.PUoMEntry
WHERE T0.InvntItem  = 'Y'
  AND T0.PUoMEntry  T0.IUoMEntry
ORDER BY PurchaseFactor DESC;

SAP HANA

-- Exposure by conversion factor magnitude in purchases
SELECT
    T0."ItemCode",
    T0."ItemName",
    T1."UgpCode"              AS "Group",
    T2."UomCode"              AS "InventoryUom",
    T3."UomCode"              AS "PurchaseUom",
    T4."UomCode"              AS "SalesUom",
    IFNULL(T5."BaseQty" / T5."AltQty", 1) AS "PurchaseFactor",
    T0."OnHand",
    T0."OnHand" * T0."AvgPrice" AS "InventoryValue"
FROM OITM T0
INNER JOIN OUGP T1 ON T0."UgpEntry"  = T1."UgpEntry"
LEFT  JOIN OUOM T2 ON T0."IUoMEntry" = T2."UomEntry"
LEFT  JOIN OUOM T3 ON T0."PUoMEntry" = T3."UomEntry"
LEFT  JOIN OUOM T4 ON T0."SUoMEntry" = T4."UomEntry"
LEFT  JOIN UGP1 T5 ON T5."UgpEntry"  = T0."UgpEntry"
                  AND T5."UomEntry"  = T0."PUoMEntry"
WHERE T0."InvntItem"  = 'Y'
  AND T0."PUoMEntry"  T0."IUoMEntry"
ORDER BY "PurchaseFactor" DESC;

Variations and frequent use cases

Production with fractional consumption. When the bill of materials consumes grams and purchasing is done in bags, define the base unit as the minimum actual consumption fraction. This way, the production cost reflects true consumption rather than a prorated average.

Variable weight sale. In food and agribusiness, the box does not always weigh the same. In these cases, the unit group does not replace batch control; it complements it. Therefore, use the base unit in kilos and record the actual weight per batch, not a fixed factor.

E-commerce and promotional packs. A six-pack is not a new unit of measure: it is a distinct item or a factor of the same group. Decide the criteria before creating the master record, because changing it later requires migrating historical transactions.

Third-party integration. If you send orders via Service Layer or receive electronic documents, always validate that the unit field is populated. When it arrives empty, SAP assumes the item's default unit, and the silent result is a receipt multiplied or divided by the factor.

Best practices and common mistakes

  1. Define the base unit in the smallest fraction you actually transact. Uploading the base to the box seems simpler, but it prevents selling by unit without decimals.
  2. Never change a factor with open historical movements. Create a new group and migrate the items in a controlled manner.
  3. Block manual editing of the units per line field For operational profiles, complete flexibility in data entry is the gateway to error.
  4. Audit monthly with query 3. A dashboard with that query detects the problem in days, not in the annual inventory.
  5. Do not confuse unit of measurement with commercial presentation. The classic mistake is to create the BOX-24 unit instead of using the factor 24. Furthermore, that habit makes any aggregated analysis impossible.
  6. Document the criterion. A file with the rule of each family is worth more than any configuration, because it survives team turnover.

Official SAP resources

Conclusion: Conversion is a business decision, not a master's field

Units of measure seem like a minor configuration because they don't have an owner. They don't belong to Warehouse, Purchasing, or Finance, and that's why they end up belonging to no one. However, they define the unit cost, the margin per line, the reorder point, and inventory accuracy. Consequently, they are a management decision disguised as a technical field.

Start simple today: run query 2 and see how much money is tied up in items without a unit group. That figure alone is usually enough to open the right conversation with your committee.

Do you want the rest of the arsenal? In the Strategic Circle, I publish tutorials like this every week, with queries ready to run in SQL Server and HANA, and with the business criteria behind every technical decision. If you lead technology in a manufacturing or distribution company, this is where the ERP stops being just a system and starts becoming an advantage.

Most Read

Ballena jorobada bajo el agua con su aleta pectoral extendida: la esperanza en la tecnología y la biomimética
La ballena que volvió: la esperanza en la tecnología y la que no cabe en un tablero
SAP data in ChatGPT: an open door at the far end of a dark room
The Tab Next Door: The SAP Data in ChatGPT That Nobody Authorized
SAP Business One Purchase Price Variance - featured image of the tutorial
SAP Business One Purchase Price Variance: Detect the Inflation in Your Buying Costs
QlikSense format changeovers: actual minutes against the standard
QlikSense Format Changeovers: the Minutes Nobody Bills
QlikSense buttons and actions: executive dashboard with indicators
QlikSense Buttons and Actions: the Dashboard that Runs the Meeting
SAP Business One Internal Reconciliation - featured image of the tutorial
SAP Business One Internal Reconciliation: Clear False Open Items

RELATED ARTICLES