In the above snippet, if lv_qty_lb was 0.051 (3 decimals), rounding to 1 decimal would give lv_lb_rounded = 0.1 (or 0.0 if below 0.05). You can adjust the dec = n or use floor()/ceil() if you need always round down or up. This programmatic approach ensures the displayed or stored value meets your requirement (e.g. no thousandths). Keep in mind rounding rules (financial rounding vs truncation) as needed.

Use an Alternative FM (if appropriate): SAP provides other function modules for unit conversion:

MATERIAL_UNIT_CONVERSION: Converts between a material’s base and alternate UoM (similar goal as MD_CONVERT). One distinction is that if you need to convert between two alternate units (neither is the base), you must call it twice (alt  to  base, then base  to  other alt). This FM uses the same underlying data (MARM/T006). It might not inherently fix a rounding issue, but it gives you control via parameters (for example, the parameter KZMEINH indicates the direction: set KZMEINH = 'X' to convert from alternate to base UoM). Some developers prefer this FM and then handle rounding manually, especially if MD_CONVERT raised exceptions in cases of missing data.

UNIT_CONVERSION_SIMPLE: This function converts between any two units of the same dimension using table T006 and can perform rounding as well. It requires that both units are defined in T006 and share a dimension (KG and LB do). You can specify a ROUND flag to let it round to the target units defined decimals. Internally, it consults T006s ANDEC for how many decimals to keep. If your materials conversion is standard, UNIT_CONVERSION_SIMPLE is a straightforward choice. Example call:

 CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

   EXPORTING

     input    = lv_qty_kg

     unit_in  = 'KG'

     unit_out = 'LB'

     round    = 'X'          " request rounding per unit settings

   IMPORTING

     output   = lv_qty_lb.

 

This will give lv_qty_lb rounded to the number of decimals defined for LB in T006 (typically 3 by default). If that is still too many, you’d still need an extra rounding step or adjust the unit’s decimal setting.

CONVERSION_FACTOR_GET: If you need to retrieve the precise conversion factor (numerator/denominator) for custom calculations, this FM provides the factor between two units. You could use it to get, say, the fraction for KG to LB, then apply a custom formula or rounding. This is more involved, but useful if you want to implement a very specific rounding policy (e.g. always round down to the nearest 0.5 LB, etc.).

Software Factory 2