SAP Function UNIT_CONVERSION_SIMPLE - Measurement unit conversion by table T006, with rounding

Parameter Reference Type Length Default Optional Text
INPUT 0 Input Value
NO_TYPE_CHECK 0 'X' X Conversion factor type check
ROUND_SIGN 0 SPACE X Rounding flag (+ up, - down, X comm.)
UNIT_IN T006-MSEHI C 3 SPACE X Unit of input value
UNIT_OUT T006-MSEHI C 3 SPACE X Unit of output value

Parameter Reference Type Length Text
ADD_CONST 0 additive constant for conversion
DECIMALS 0 Number of decimal places for rounding
DENOMINATOR 0 Denominator for conversion
NUMERATOR 0 Numerator for conversion
OUTPUT 0 Output value

Exception Text
CONVERSION_NOT_FOUND Conversion factor could not be determined
DIVISION_BY_ZERO Division by zero trapped
INPUT_INVALID Input value is not a number
OUTPUT_INVALID OUTPUT parameter is not a number
OVERFLOW Field overflow
TYPE_INVALID an output parameter is not a number
UNITS_MISSING no units specified
UNIT_IN_NOT_FOUND UNIT_IN is not maintained
UNIT_OUT_NOT_FOUND UNIT_OUT is not maintained


Functionality
This FM converts values from one measurement unit to another and roundsthe result to the number of decimal places maintained in themeasurement unit table, if necessary. The rounding is up ('+'), down('-'), commercial ('X') or no rounding (SPACE), depending on theparameter ROUND_SIGN.
It can also be used for rounding according to the measurement unittable only. In this case UNIT_IN = UNIT_OUT.
Conversion requires that both units are maintained in the measurementunit table and have the same dimension and are notboth without dimension.
Rounding is also possible for dimensionless units.
Example
DATA: VALUE_IN TYPE F,
VALUE_OUT TYPE F,
UNIT_IN LIKE T006-MSEHI,
UNIT_OUT LIKE T006-MSEHI.
...
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
INPUT = VALUE_IN
ROUND_SIGN = 'X'
UNIT_IN = UNIT_IN
UNIT_OUT = UNIT_OUT
IMPORTING
OUTPUT = VALUE_OUT
EXCEPTIONS
CONVERSION_NOT_FOUND = 01
DIVISION_BY_ZERO = 02
INPUT_INVALID = 03
OVERFLOW = 04
OUTPUT_INVALID = 05
UNITS_MISSING = 06
UNIT_IN_NOT_FOUND = 07
UNIT_OUT_NOT_FOUND = 08.
Notes
  • If the Parameter OUTPUT is not specified in the function module call,
  • the exception OUTPUT_INVALID is generated. If only the conversionfactors are specified, the function module CONVERSION_FACTOR_GET can beused.
    INCLUDE 'FU_INF_BUF' OBJECT DOKU ID TX
    If this parameter is not specified when the function module is calledin the program, the exception OUTPUT_INVALID is raised.
    • ' '(SPACE)

    • The output parameters NUMERATOR, DENOMINATOR andADD_CONST are type-checked and checked for overflow.
      • 'X'

      • No check.
        By default no check is made.
        If one of the three output parameters NUMERATOR, DENOMINATOR andADD_CONST is not specified at the call, NO_TYPE_CHECK ='X' must be specified (default).

817584Generated composition displays invalid units of measure
430898Internal error when converting units
409928Tank assignement not done when capacity compare not poss.