cancel
Showing results for 
Search instead for 
Did you mean: 

unit conversions

Former Member
0 Kudos

Hello everyone,

Is there any generalised function module which would convert one unit values to others....i have tried UNIT_CONVERSION_SIMPLE...but wen testing it is showing invalid_input exception...

thanks,

kiran.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hai kiran,

There are Several Function Module...

Check out there functionality as per your requirement...

· CONVERSION_FACTOR_GET

With this function module, you determine the conversion factors for the conversion of a measurement unit into another using the measurement units table. This does not apply to measurement units within a dimension.

The module also returns the number of decimal places to which the values in the unit UNIT_OUT are to be rounded. This also applies to units with no dimension.

The following formula applies for the conversion:

(value in the unit UNIT_OUT) = (value in the unit UNIT_IN) * numerator/denominator + additive constant.

· ROUND

With this function module, you round a value to the specified number of decimal places. You can choose between three rounding types:

- Rounding up

- Rounding down

- Commercial rounding

The rounding is performed internally with the same field type as that of the field passed.

Rounding errors can thus occur when rounding a FLOAT value. If you want a high degree of accuracy, the passed field should have the type P.

· SI_UNIT_GET

You pass either a unit or a dimension to this function module to get the SI unit. If you pass both a unit and a dimension, the SI unit for the dimension is returned.

· UNIT_CONVERSION_WITH_FACTOR

With this function module, you convert a value according to the factor passed.

· UNIT_CORRESPONDENCE_CHECK

With this function module, you can check whether the two units passed belong to the same dimension.

· UNIT_GET

With this function module, you get the appropriate measurement unit for the specified dimension and conversion factor.

· UNIT_CONVERSION_SIMPLE

With this function module, you convert a value using the measurement unit table, and round it, if appropriate.

You can also perform the rounding without conversion.

Conversion with this function module requires that the measurement unit table is maintained for both units, and that both units belong to the same dimension, i.e. also that they have dimensions.

The rounding can, however, also be performed for units which have no dimension.

CONVERT_TO_LOCAL_CURRENCY - Conversion of currency

HRCM_AMOUNT_TO_STRING_CONVERT - Convert amount to string

HRCM_STRING_TO_AMOUNT_CONVERT - Convert amount from string

CLOI_PUT_SIGN_IN_FRONT Move the negative sign from the left hand side of a number, to the right hand side of the number. Note that The result will be left justified (like all

character fields), not right justifed as numbers normally are.

CONVERT_TO_FOREIGN_CURRENCY Convert local currency to foreign currency.

CONVERT_TO_LOCAL_CURRENCY Convert from foreign currency to local currency

Do Reward Points to replies if found useful...

Regards,

Srikanth.

Answers (6)

Answers (6)

Former Member
0 Kudos
Former Member
0 Kudos

Thanks friends for giving me those details,

it got worked out here with a minor changes.

Former Member
0 Kudos

Hi

Are you trying to test that FM by SE37?

If it's so I think the system can't understand your input is a number, but it's a char for it.

So you should write a little program to test that fm.

Max

Former Member
0 Kudos

hai kiran,

just check out this link..........

http://www.geocities.com/victorav15/sapr3/abapfun.html

all the function modules for unit conversions are available here...............

regards

selvi

Former Member
0 Kudos

hi,

you can try out the following function modules:

<b>CF_UT_UNIT_CONVERSION</b> : this may solve your problem.

Other related function modules are:

<b>CO_RU_UNIT_CONVERSION

J_1I6_UNIT_CONVERSION </b>

C14W_CHAR_NUMBER_CONVERSION

C14W_NUMBER_CHAR_CONVERSION

CONVERSION_EXIT_CUNIT_INPUT

CONVERSION_EXIT_CUNIT_OUTPUT

CONVERSION_EXIT_LUNIT_INPUT

CONVERSION_EXIT_LUNIT_OUTPUT

DIMENSION_GET_FOR_UNIT

hope this solves your problem

if satisfied, do reward with the points.

regards

kunal.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Here is the sample code.

CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

EXPORTING

input = weight_unclaimed

unit_in = unit_of_weight

unit_out = 'KG'

IMPORTING

output = weight_unclaimed

EXCEPTIONS

OTHERS = 1.

Chek this link for more info.

http://www.sap4.com/modules.php?name=Funciones&func=funcionView&funcionid=8

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

Former Member
0 Kudos

Kiran,

What kind of units are you trying to convert? To use UNIT_CONVERSION_SIMPLE, the units must be maintained in table T006. (See Function Module Documentation).

If you are trying to convert Material Units then try function module MATERIAL_UNIT_CONVERSION. However here, the units must be maintained in the Material Alternate units of measure.

Chris