If for all of these UOM class, you have default UOM BOX and Base UOM PCS… You could just link a UOMCONV table to part and put a filter on the UOMCONV table of “UOMCode = “BOX””. then in a calculated field multiply the inventory by ConvFactor.
This would give you the number of pieces including partial boxes. If you want both the number of FULL boxes and PCS from full boxes, just add in some SQL math functions to round down. This would be the floor function.
Came across this topic while looking for something else but i have built something for this awhile ago that displays either the Part Specific UOM Conversion value, if applicable, or the UOM Class conversion factor if not part specific.
I join this as a subquery on PartNum = PartNum and UOMCode = PL and then i can take whatever value in OrderDtl.OrderQty * UOM.uomcConvFactor to get the quantity in PL (pallets), or do the reverse with OrderDtl.SellingQty / UOM.uomcConvFactor and bring the PL values back to base.
SELECT
conv.PartNum,
conv.PartDescription,
conv.InActive,
conv.IUM,
uom2.UOMDesc ‘IUM Description’,
conv.PartUOMClassID ‘Part Specific’,
conv.UOMClassID ‘UOM Class’,
conv.UOMCode,
uom.UOMDesc,
conv.uomcConvFactor
FROM
(
SELECT
p.Company,
p.PartNum,
p.PartDescription,
p.IUM,
p.InActive,
‘’ ‘PartUOMClassID’,
uomc.UOMClassID ‘UOMClassID’,
uomc.UOMCode ‘UOMCode’,
uomc.ConvFactor ‘uomcConvFactor’
FROM Erp.Part p
INNER JOIN Erp.UOMConv uomc
ON p.Company = uomc.Company
AND p.UOMClassID = uomc.UOMClassID
WHERE p.Company = ‘’
AND p.Inactive = 0
AND NOT EXISTS
(
SELECT
PartNum
FROM Erp.PartUOM
WHERE Company = ‘’
AND p.PartNum = PartUOM.PartNum
AND uomc.UOMCode = PartUOM.UOMCode
AND PartUOM.ConvFactor <> 0
)
UNION ALL
SELECT
p2.Company,
p2.PartNum,
p2.PartDescription,
p2.IUM,
p2.InActive,
p2.UOMClassID ‘p2UOMClassID’,
‘’ UOMClassID,
puom.UOMCode ‘puomUOMCode’,
puom.ConvFactor ‘puomConvFactor’
FROM Erp.Part p2
INNER JOIN Erp.PartUOM puom
ON p2.Company = puom.Company
AND p2.PartNum = puom.PartNum
WHERE p2.Company = ‘’
AND p2.Inactive = 0
AND NOT EXISTS
(
SELECT
*
FROM Erp.UOMConv
WHERE Company = ‘’
AND UOMConv.UOMClassID = p2.UOMClassID
AND UOMConv.UOMCode = puom.UOMCode
AND puom.ConvFactor = 0
)
) conv
LEFT JOIN Erp.UOM uom
ON uom.Company = conv.Company
AND uom.UOMCode = conv.UOMCode
LEFT JOIN Erp.UOM uom2
ON uom2.Company = conv.Company
AND uom2.UOMCode = conv.IUM
ORDER BY conv.PartNum,
conv.UOMCode
;