SAP Function EHSWA_490_UNIT_CONVERSION - Conversion of Units of Measure

Parameter Reference Type Length Default Optional Text
I_MATNR EHSWAE_WASTE C 18 X Material That Represents the Waste
I_QUANTITY_SOURCE EHSWAE_EAINTAM P 7 Original Quantity (Source)
I_UNIT_SOURCE EHSWAE_EAINTAMU C 3 Unit of Source Quantity
I_UNIT_TARGET EHSWAE_EAINTAMU C 3 Unit of Target Quantity

Parameter Reference Type Length Text
E_FLG_ERROR ESP1_BOOLEAN 0 Indicator: Errors Occurred?
E_FLG_WARNING ESP1_BOOLEAN 0 Indicator: Warnings Occurred?
E_QUANTITY_TARGET EHSWAE_EAINTAM P 7 Converted Quantity (Target)
E_UNIT_CONV_SUBRC_GLB SYST-SUBRC I 4 Exact SY-SUBRC Quantity Conversion Without Material
E_UNIT_CONV_SUBRC_MAT SYST-SUBRC I 4 Exact SY-SUBRC Quantity Conversion with Material

Exception Text
ERR_CONVERSION_GLOBAL Error When Converting Quantity Without Material Reference
ERR_CONVERSION_MATERIAL Error When Converting Quantity with Material Reference
PARAMETER_ERROR

Functionality
With this function module, you can convert a source quantity(I_QUANTITY_SOURCE) with a unit of measure (I_UNIT_SOURCE) to a targetquantity (E_QUANTITY_TARGET) with a different unit of measure(I_UNIT_TARGET). You can convert positive and negative quantities. Inaddition, the function module also checks whether conversion is evennecessary. To improve performance, it automatically transfers the sourcequantity directly to the target quantity if the units of measure for thesource and target quantities are the same. This means the callingprogram does not need to run this check.
For quantities to be converted, you must store the necessary conversionrules in the system. Using the parameter I_MATNR (waste material), youcan control which conversion rules are used:

  • If you do not supply a waste material when calling the function module,
  • the global conversion rules are used. You specify these for the variousunits of measurement in Customizing for General Settings underCheck Units of Measurement.
    • If you supply a waste material when calling the function module, the
    • conversion rules are used that are stored for this material in thematerial master. If no suitable conversion rule is found, the warningindicator is set and the function module attempts to use a suitableglobal conversion rule.

      Import Parameters
      I_UNIT_SOURCE,,Unit of measure for source quantity (source)
      I_UNIT_TARGET,,Unit of measure for target quantity (target)
      I_QUANTITY_SOURCE,,Source quantity (source), that is original quantitythat is to be converted to the target unit of measure
      I_MATNR,,Material that represents the waste; if a material is specifiedin the call, the conversion rules for the material are given preferenceover the global conversion rules (see above)

      Export Parameters
      E_QUANTITY_TARGET,,Target quantity that was converted to the target unitof measure
      E_FLG_ERROR,,Error indicator that specifies whether an error occurredduring quantity conversion (this is equivalent to SY-SUBRC <> 0)
      E_FLG_WARNING,,Warning indicator that specifies whether a warningoccurred during quantity conversion (for example, during conversion withreference to a material if no suitable conversion rule can be determinedfor the material and a global conversion rule must be used)
      E_UNIT_CONV_SUBRC_GLB,,Parameter that contains the exact error code(SY-SUBRC) from the function module UNIT_CONVERSION_SIMPLE, with whichthe global quantity conversion is to be carried out without reference toa material; the error code is also set if a quantity conversion withreference to a material was not successful and the subsequent globalquantity conversion also failed.
      E_UNIT_CONV_SUBRC_MAT,,Parameter that contains the exact error code(SY-SUBRC) from the function module EHSWA_490_MAT_UNIT_CONVERSION (onthe basis of the function module MATERIAL_UNIT_CONVERSION), with whichthe quantity conversion with material reference is to be carried out;the error code is also set (with the warning indicator E_FLG_WARNING) ifthe subsequent global quantity conversion could be carried outsuccessfully.

      Exceptions
      PARAMETER_ERROR,,Exception that is triggered if required inputparameters are not set or are invalid (for example, if no units ofmeasure are supplied for the source or target quantities or if the unitsof measure supplied are initial)
      ERR_CONVERSION_GLOBAL,,Exception that is triggered if an error occursduring global quantity conversion without reference to a material; theparameter E_UNIT_CONV_SUBRC_GLB is filled with the corresponding errorcode.
      ERR_CONVERSION_MATERIAL,,Exception that is triggered if an error occursduring quantity conversion with reference to a material and thesubsequent global quantity conversion (without material reference) alsoleads to an error. If, however, the subsequent global quantityconversion without material reference does not lead to an error, onlythe warning indicator E_FLG_WARNING is set and no exception istriggered. The parameter E_UNIT_CONV_SUBRC_MAT is filled with thecorresponding error code in the case of a warning or an error.