Item Unit of Measure Conversion Integrity SQL Query Generator
Wrong unit of measure conversions quietly produce wrong receipts, wrong costs and wrong MRP quantities. This generator builds three read-only SQL checks for missing, invalid and non-reciprocal conversion factors, using your own table and column names.
Fill in
Your ERP item or material table
Allowed difference from 1 when factor A to B is multiplied by B to A
1. Items whose purchase UoM has no conversion to the stock UoM
SELECT i.item_no, i.purch_uom, i.stock_uom
FROM item_master i
WHERE i.purch_uom <> i.stock_uom
AND NOT EXISTS (
SELECT 1 FROM item_uom_conversion c
WHERE c.item_no = i.item_no
AND c.from_uom = i.purch_uom
AND c.to_uom = i.stock_uom
)
ORDER BY i.item_no;2. Conversion rows with zero, null or negative factors
SELECT c.item_no, c.from_uom, c.to_uom, c.factor FROM item_uom_conversion c WHERE c.factor IS NULL OR c.factor <= 0 ORDER BY c.item_no, c.from_uom;
3. Pairs where A to B times B to A is not 1
SELECT a.item_no, a.from_uom AS uom_a, a.to_uom AS uom_b,
a.factor AS factor_ab, b.factor AS factor_ba,
a.factor * b.factor AS product
FROM item_uom_conversion a
JOIN item_uom_conversion b
ON b.item_no = a.item_no
AND b.from_uom = a.to_uom
AND b.to_uom = a.from_uom
WHERE a.from_uom < a.to_uom
AND ABS(a.factor * b.factor - 1) > 0.0001
ORDER BY a.item_no;Table and column names here are generic placeholders, not real ERP schema names. Map them to your own ERP, for example the item and UoM conversion tables of SyteLine, Epicor, Oracle EBS or SAP (where conversions sit on material master alternative UoM data). Some ERPs store conversions only in one direction or as numerator and denominator pairs, in which case adjust query 3. Run read-only on a reporting copy first.
Automate UoM data quality checks
Want these checks to run on a schedule against your ERP with results sent to data owners? We can set that up.
Optional. The tool and every export work without this. No spam.
How to use the generator
Fill the field names to match your ERP item table and its UoM conversion table, then copy the SQL into your database tool. The first query finds items bought in a unit that cannot be converted to the stock unit. The second finds conversion rows with null, zero or negative factors. The third finds pairs where the factor from A to B and back from B to A do not multiply to one within your tolerance. Export the result sets to Excel for the data steward to fix.
The logic behind the checks
A conversion between two units is a ratio, so the reverse must be its reciprocal. Any pair that breaks this will give a different quantity depending on which direction a transaction uses. Missing conversions force users to override quantities by hand. Zero or negative factors can drop quantities to nothing or flip signs. Together these three checks catch most UoM errors that cause cost variances and receiving disputes.
- Query 1: coverage gaps
- Query 2: invalid values
- Query 3: reciprocal consistency
- All three are SELECT only
ERP notes and mistakes
Some ERPs hold conversions at item level, others have a global table plus item overrides, and some store a numerator and a denominator. Adapt the joins accordingly and check how your system treats rounding and decimal places per unit. A frequent mistake is fixing a factor without checking open purchase orders and on-hand inventory held in the changed unit. Plan the correction with a transaction freeze or a controlled adjustment, and keep a backup of the old values.
Frequently Asked Questions
Will these queries change my data?
No. All three are SELECT statements and only read data. Still run them first on a reporting copy or off-peak, since large item and conversion tables can take time without suitable indexes.
Why must reciprocal factors multiply to 1?
If 1 box equals 12 each, then 1 each must equal 1/12 box. If the two stored factors do not multiply to 1, converting there and back changes the quantity, so results depend on the direction of the transaction.
My ERP stores numerator and denominator. Can I use this?
Yes with a small change. Replace the factor column by numerator divided by denominator in each query, taking care to avoid integer division and zero denominators in your database.
Does it work on SAP?
Use it as a pattern. In SAP, alternative units are stored with numerator and denominator against the material, so map the columns accordingly and check with your Basis or data team before running against production tables.
If you want these checks scheduled, scored and routed to the right data owner, we can build that on top of your ERP data with read-only access.
Related Tools
Unit of Measure Conversion Reference
Searchable table of common UoM conversion factors for ERP item masters, with exact definitions where they exist.
Developer ToolsExcel CONVERT Function Engineering Unit Formula Generator
Fill a cell reference and two unit codes to get ready-to-paste CONVERT formulas, plus a torque conversion since CONVERT has no torque units.
Quality & InspectionImperial to Metric Conversion Error Prevention Checklist
A 30-point checklist for catching unit mix-ups between drawings, suppliers, ERP data, programs and inspection.
Engineering & PLMFractional Inch to Decimal and mm Chart
Every 1/32 inch from 1/32 to 1 inch with decimal inches and exact millimetres, searchable and exportable.
More Developer Tools tools
See all- SAP Sales Order ABAP SELECT Generator (VBAK, VBAP, VBFA)
- SAP Sales Order Create BAPI ABAP Generator (BAPI_SALESORDER_CREATEFROMDAT2)
- SAP ABAP Open Items SELECT Generator
- SAP ACDOCA SQL Query Generator
- SAP QM Inspection Lot ABAP SELECT Generator
- SAP Quality Notification Pareto SQL Query Generator
- SAP QM Usage Decision BAPI Skeleton
- ABAP Custom Exception Class Generator
- ABAP Unit Test Class Generator