Unit Conversion Precision Issue (MD_CONVERT_MATERIAL_UNIT KG→LB)
Overview of the Issue
When using SAP’s MD_CONVERT_MATERIAL_UNIT function to convert quantities from kilograms (KG) to pounds (LB), users have reported unexpected decimal precision issues. In practice, a very small weight in KG can convert to a fractional LB value with several decimal places (for example, 0.023 KG converts to roughly 0.0507 LB, which appears as 0.051 LB when rounded to three decimals). The expectation for finished goods is that such tiny converted quantities would be rounded off (often to 0.000 LB or another sensible value) instead of showing spurious decimals. This discrepancy is due to how SAP handles unit-of-measure (UoM) conversions and rounding. Below, we explore known causes and solutions:
SAP’s Unit Conversion Mechanism (KG to LB)
-
Fixed Conversion Factor: SAP defines unit conversions in its standard unit table. 1 pound (LB) is defined as exactly 0.45359237 kilograms (KG), meaning 1 KG ≈ 2.20462262185 LBrapidtables.com. This fixed ratio (set in UoM customizing via transaction CUNI) ensures consistency. However, it also means converting a small KG quantity yields a fractional LB value that is not a “neat” rounded number. For example, a few grams in KG will convert to a hundredth of a pound.
-
Dimension-Based Conversion: SAP distinguishes between material-specific conversions and general unit conversions by dimension. For weight units like KG and LB (both in the “Mass” dimension), SAP can use the global conversion factor from the units table T006 if no material-specific rule is maintained. In fact, for units with defined physical dimensions (length, weight, volume, etc.), conversion is calculated from table T006 (or via the function
CONVERSION_FACTOR_GET
for precision)sapnet.ru. This ensures that even if a material has no explicit KG↔LB conversion in its master data, the system knows how to convert based on standard physics. -
Material Master vs. Global Conversion: If the material’s alternate unit (LB) is maintained in the material master (table MARM), SAP will use the material-specific conversion factor (MARM-UMREZ/UMREN). Otherwise, it falls back to the standard ratio in T006sapnet.ru. In either case, the resulting value may include fractional pounds unless it divides evenly. (E.g. if MARM defines 1 LB = 0.45 KG as an approximation, the conversion will still produce a fractional result, just a different one.) It’s important to ensure the material’s UoM conversion factors are accurate; any approximation in MARM (e.g. rounding 1 LB to 0.45 KG) can introduce additional error in the converted quantity.
Decimal Precision and Rounding in SAP
-
Standard Quantity Field Precision: Most SAP quantity fields (domain QUAN) allow up to 3 decimal places by default. The function module MD_CONVERT_MATERIAL_UNIT itself returns the result in a quantity field format. In fact, one known limitation is that MD_CONVERT_MATERIAL_UNIT will not output more than 3 decimals of precision – it was designed around the standard 3-decimal QUAN field (e.g. EKPO-MENGE)tcodesearch.com. This means even if a unit is defined with more decimal precision, this function truncates/rounds the result to three decimal places. (For example, a custom UoM requiring 4 decimals would not get 4 decimals output from this FMtcodesearch.com.)
-
T006 Configuration (ANDEC & DECAN): SAP’s unit table T006 has fields that control rounding and display of decimals for each unit:
-
ANDEC – The number of decimal places for calculations/rounding for that unitcommunity.sap.com. For instance, if ANDEC = 3 for LB, conversions to/from LB are rounded to 3 decimal places internally.
-
DECAN – The number of decimal places for display (presentation) of that unit. This can be set lower than ANDEC if you want to show fewer decimals than the system calculates. For example, LB might be set to display 0 or 1 decimal in documents even though calculations use 3.
However, note: These settings affect how values are rounded for output, not the raw stored value limits. SAP Note 931971 explains that even if you configure 0 decimals for a unit in customizing, the actual stored quantity can still have up to 3 decimals because of the field definitionstechno.net. In other words, customizing influences display and rounding messages, but does not prevent the system from holding small fractional values. This is why you might see 0.051 LB in a calculation context even if you expected 0.000 – the field allows it, and it’s rounded to 3 decimals (per ANDEC) rather than completely dropped.
-
-
Why 0.051 instead of 0.000? In the example given, the small KG quantity converted to 0.0507 LB and then was rounded (to three decimals) as 0.051. The user expected 0.000 presumably because such a tiny weight is negligible. SAP’s standard logic, however, will round .0507 up to .051 if rounding to 3 decimals (since 0.0507 * 1000 ≈ 50.7, which rounds up to 51). The “excessive” decimals are simply a byproduct of faithfully converting according to the precise factor and keeping three decimal digits of precision. In many business cases (like finished goods weight), showing thousandths of a pound isn’t useful – but the system doesn’t automatically zero it out unless explicitly told to do so.
Impact of Material Master Data and UoM Settings
-
Material Master UoM (MARM): Check if the material’s alternative unit conversion (KG↔LB) is maintained in the material master. If yes, verify the numerator/denominator (UMREZ/UMREN) values. These should represent the conversion as accurately as possible. For example, ideally 1 LB = 0.45359237 KG. If the material master uses a simplified ratio (e.g. 1 LB = 0.454 KG), the conversion to LB might be slightly off, causing unexpected decimals. Using a more exact conversion factor in MARM (perhaps 45359/100000 kg per lb, or similar) can minimize rounding error. If the material does not list LB as an alternate unit, then MD_CONVERT will rely on the standard ratio from T006. In that case, the precision issue is purely due to the standard factor and rounding, not a data error.
-
Allowed Decimal Places: Consider the nature of your finished good. If it’s something that realistically should be weighed in whole pounds (no fractions), you might configure the unit LB in customizing to have 0 decimal places for display (T006-DECAN = 0). This way, in outputs or transactions, SAP will round the quantity to a whole number. But remember, internally the calculation may still carry small fractionsstechno.net. Also, if the material should never have fractional LB, you could enforce this by setting the “no decimal” flag in material master for that unit of measure (if available) or via input validation. Some industries maintain certain UoM as whole-number only. Ensure your config aligns with business expectations to avoid seeing tiny decimals at all.
-
Known SAP Notes/Bugs: There aren’t specific SAP Notes addressing a “bug” in MD_CONVERT_MATERIAL_UNIT for KG→LB rounding – because the behavior is largely as designed. The function accurately converts and rounds to the allowed decimals. The “issue” is often expectation vs. system design. That said, there are notes on unit conversion and decimal handling in general. For example:
-
SAP Note 77525 – “Quantity unit conversion in inventory management” and related notes discuss rounding issues in inventory movements (ensuring that when converting units, the results align with configured decimal places).
-
SAP Note 95869 – “Decimal places for quantity fields (type QUAN)” confirms that quantity fields generally allow 3 decimals, and inconsistency can arise if you expected fewer.
These underscore that you may need to implement custom rounding if your business requires stricter precision than SAP’s standard. (No specific fix is provided for MD_CONVERT’s behavior, since it’s using core logic.)
-
Rounding Strategies and Workarounds
To ensure “correctly rounded” quantities during unit conversion, especially for small values, consider the following strategies:
-
Post-Conversion Rounding: After calling MD_CONVERT_MATERIAL_UNIT (or any conversion function), apply your own rounding logic to the result. For example, in ABAP you can use the built-in rounding function to round or floor the value to the desired precision.
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
i_matnr = lv_matnr
i_in_me = 'KG'
i_out_me = 'LB'
i_menge = lv_qty_kg
IMPORTING
e_menge = lv_qty_lb. " result in LB (FLOAT or QUAN)
IF sy-subrc = 0.
" Custom rounding: for example, round to 1 decimal place
DATA(lv_lb_rounded) = round( val = lv_qty_lb dec = 1 ).
ENDIF.