Application Development and Automation 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: 
Read only

Conversion for units

Former Member
0 Likes
2,414

Hi all,

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...

kindly help!!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,380

HI Srinivas

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...

Cheers:)

Mithlesh

2 REPLIES 2
Read only

Former Member
0 Likes
1,380

Hi

Write a little program to test that function.

If you test it by SE37, fm can't understand the input is numeric field, but it's a char field for it.

Max

Read only

Former Member
0 Likes
1,381

HI Srinivas

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...

Cheers:)

Mithlesh