Skip to Content
avatar image
Former Member

converting the units of a weight field

Hi,

I want to convert weight field's units into KG. i want to add the all weights but i want to convert it into KG before. as it may contain the units other than KG. plz tell me its veryvery urgent.

i think u understood..

weight( (VBRP-BRGEW)

units (VBRP-GEWEI)

Kumar

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Oct 19, 2005 at 05:21 AM

    Hi,

    The following is from documentation.Have a look at it.Give unit_out = 'KG'.

    Kindly reward points by clikcing the star on the left of reply,if it helps.

    Functionality

    This FM converts values from one measurement unit to another and rounds the result to the number of decimal places maintained in the measurement unit table, if necessary. The rounding is up ('+'), down ('-'), commercial ('X') or no rounding (SPACE), depending on the parameter ROUND_SIGN.

    It can also be used for rounding according to the measurement unit table only. In this case UNIT_IN = UNIT_OUT.

    Conversion requires that both units are maintained in the measurement unit table and have the same dimension and are not both 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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 19, 2005 at 05:13 AM

    Hi,

    Try the function

    UNIT_CONVERSION_SIMPLE - It convert weights from one UOM to another.

    Thanks,

    Ruthra

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 19, 2005 at 05:17 AM

    this sample code must help u ....

    &----


    *& Form z_unit_conversion_kg

    &----


    • This form is used to convert weight unit in 'LB'

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM Z_UNIT_CONVERSION_LB.

    I_LN_ITEMS-BRGEW_KG = I_LN_ITEMS-BRGEW.

    CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

    EXPORTING

    INPUT = I_LN_ITEMS-BRGEW

    UNIT_IN = C_KG

    UNIT_OUT = C_LB

    IMPORTING

    OUTPUT = I_LN_ITEMS-BRGEW_LB.

    I_LN_ITEMS-NTGEW_KG = I_LN_ITEMS-NTGEW.

    CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

    EXPORTING

    INPUT = I_LN_ITEMS-NTGEW

    UNIT_IN = C_KG

    UNIT_OUT = C_LB

    IMPORTING

    OUTPUT = I_LN_ITEMS-NTGEW_LB.

    MODIFY I_LN_ITEMS TRANSPORTING NTGEW_KG NTGEW_LB.

    ENDFORM. " z_unit_conversion_lb

    &----


    *& Form z_unit_conversion_lb

    &----


    • This form is used to convert weight unit in 'KG'

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM Z_UNIT_CONVERSION_KG.

    I_LN_ITEMS-BRGEW_LB = I_LN_ITEMS-BRGEW.

    CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

    EXPORTING

    INPUT = I_LN_ITEMS-BRGEW

    UNIT_IN = C_LB

    UNIT_OUT = C_KG

    IMPORTING

    OUTPUT = I_LN_ITEMS-BRGEW_KG.

    MODIFY I_LN_ITEMS TRANSPORTING BRGEW_LB BRGEW_KG.

    I_LN_ITEMS-NTGEW_LB = I_LN_ITEMS-NTGEW.

    CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

    EXPORTING

    INPUT = I_LN_ITEMS-NTGEW

    UNIT_IN = C_LB

    UNIT_OUT = C_KG

    IMPORTING

    OUTPUT = I_LN_ITEMS-NTGEW_KG.

    MODIFY I_LN_ITEMS TRANSPORTING NTGEW_LB NTGEW_KG.

    ENDFORM. " z_unit_conversion_kg

    &----


    *& Form z_unit_conversion_kg_lb

    &----


    • This form is used to convert weight unit in 'KG' and 'LB'

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM Z_UNIT_CONVERSION_KG_LB.

    CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

    EXPORTING

    INPUT = I_LN_ITEMS-BRGEW

    UNIT_IN = I_LN_ITEMS-GEWEI

    UNIT_OUT = C_KG

    IMPORTING

    OUTPUT = I_LN_ITEMS-BRGEW_KG.

    CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

    EXPORTING

    INPUT = I_LN_ITEMS-BRGEW_KG

    UNIT_IN = C_KG

    UNIT_OUT = C_LB

    IMPORTING

    OUTPUT = I_LN_ITEMS-BRGEW_LB.

    MODIFY I_LN_ITEMS TRANSPORTING BRGEW_KG BRGEW_LB.

    CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

    EXPORTING

    INPUT = I_LN_ITEMS-NTGEW

    UNIT_IN = I_LN_ITEMS-GEWEI

    UNIT_OUT = C_KG

    IMPORTING

    OUTPUT = I_LN_ITEMS-NTGEW_KG.

    CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

    EXPORTING

    INPUT = I_LN_ITEMS-NTGEW_KG

    UNIT_IN = C_KG

    UNIT_OUT = C_LB

    IMPORTING

    OUTPUT = I_LN_ITEMS-NTGEW_LB.

    MODIFY I_LN_ITEMS TRANSPORTING NTGEW_KG NTGEW_LB.

    ENDFORM. " z_unit_conversion_kg_lb

    Add comment
    10|10000 characters needed characters exceeded