Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Unit of measurement conversion

Former Member
0 Kudos

Hi all

does anyone know a function module that allow me to convert beetween different unit of measurement.

For instance from liter to KG?

Thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Thank you all

the function MATERIAL_UNIT_CONVERSION works fine if I have the material it can

convert from different unit of measurement, but whan I don't have the material I have

to use UNIT_CONVERSION_SIMPLE and this returns to me anythig. For istance if I try to convert

50 L to KG it does nothing.

Someone can help me?

Thanks

8 REPLIES 8

kanthimathikris
Employee
Employee
0 Kudos

chk this function module UNIT_CONVERSION_SIMPLE

Former Member
0 Kudos

hi,

check it this fm CF_UT_UNIT_CONVERSION

I hope helps.

regards,

srini

Former Member
0 Kudos

Hi!

Use UNIT_CONVERSION_SIMPLE or MATERIAL_UNIT_CONVERSION.

Regards,

Maxim.

Former Member
0 Kudos

Hi,

You can make use the function modules,

1.UNIT_CONVERSION_SIMPLE

2. Material_unit_conversion,

Hope this helps,

Rgds,

Former Member
0 Kudos

Thank you all

the function MATERIAL_UNIT_CONVERSION works fine if I have the material it can

convert from different unit of measurement, but whan I don't have the material I have

to use UNIT_CONVERSION_SIMPLE and this returns to me anythig. For istance if I try to convert

50 L to KG it does nothing.

Someone can help me?

Thanks

0 Kudos

Not sure how you would covert from liters to kilograms..

See the following program....

Enter 50 in the first field

Enter G in the second field

Enter KG in the third field

Now hit enter.

Notice the fourth field is the quantity in KG.




report zrich_0001.


parameters: p_qtyi type p decimals 2,
            p_uomi type t006a-MSEHI,
            p_uomo type t006a-MSEHI,
            p_qtyo type p decimals 2.

at selection-screen.

call function 'UNIT_CONVERSION_SIMPLE'
  exporting
    input                      = p_qtyi
*   NO_TYPE_CHECK              = 'X'
*   ROUND_SIGN                 = ' '
   unit_in                    = p_uomi
   unit_out                   = p_uomo
importing
*   ADD_CONST                  =
*   DECIMALS                   =
*   DENOMINATOR                =
*   NUMERATOR                  =
   output                     = p_qtyo
* EXCEPTIONS
*   CONVERSION_NOT_FOUND       = 1
*   DIVISION_BY_ZERO           = 2
*   INPUT_INVALID              = 3
*   OUTPUT_INVALID             = 4
*   OVERFLOW                   = 5
*   TYPE_INVALID               = 6
*   UNITS_MISSING              = 7
*   UNIT_IN_NOT_FOUND          = 8
*   UNIT_OUT_NOT_FOUND         = 9
*   OTHERS                     = 10
          .
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.



Regards,

Rich heilman

0 Kudos

Hi Alessandro,

You cannot convert litres to kilos or any such non-standard conversions with this function module. This is useful only to do standard unit conversions of the same DIMID(dimension ID specifies whether the unit is for measuring MASS or VOLUME or LENGTH etc).

Imagine you have a litre of crude oil and a litre of water. Obviously they don't convert to the same KG weight. So for such conversions you have to maintain the conversion factors in the material master. But 1 litre of crude oil and 1 litre of water convert to the same number of gallons, because both are the same measurement group.

Hope this clarifies.

Srinivas

Former Member
0 Kudos

Hi all,

I am trying to use the FM 'UNIT_CONVERSION_SIMPLE' to convert the values into KG.

Here w_gross_ship = 1000

wa_vbrkk-gewei = LB

'c_grossinkg' = A constant Value 'KG'.

w_gross_ship_kg = Output I need in KG.

When tried to execute the FM in Se37 with the values as above it is showing an error

Exception INPUT_INVALID

Message ID: BM

Message: Please use a number field for the input value

CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

EXPORTING

input = w_gross_ship

  • NO_TYPE_CHECK = 'X'

  • ROUND_SIGN = ' '

UNIT_IN = wa_vbrkk-gewei

UNIT_OUT = 'c_grossinkg'

IMPORTING

  • ADD_CONST =

  • DECIMALS =

  • DENOMINATOR =

  • NUMERATOR =

OUTPUT = w_gross_ship_kg

  • EXCEPTIONS

  • CONVERSION_NOT_FOUND = 1

  • DIVISION_BY_ZERO = 2

  • INPUT_INVALID = 3

  • OUTPUT_INVALID = 4

  • OVERFLOW = 5

Please help me .

Thanks in advance