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
check out this link.
http://www.sapgenie.com/abap/functions.htm
http://fuller.mit.edu/SAPDocs/conversion_exits_in.htm
this may help you.
Do Reward Points to replies if found useful...
hi,
Check the link.
http://www.sapgenie.com/abap/functions.htm
http://fuller.mit.edu/SAPDocs/conversion_exits_in.htm
You can use FM CONVERT_TO_LOCAL_CURRENCY or CONVERT_TO_FOREIGN_CURRENCY for currency conversion
There are many others available. Check with unitconvert* and convertcurrency*.
UNIT_CONVERSION_WITH_FACTOR or UNIT_CONVERSION_SIMPLE for unit conversion.
Regards,
Richa
Hi Kiran,
1) Use Function Module <b>UNIT_CONVERSION_SIMPLE</b>.
DATA:
L_UNIT1 LIKE T006-MSEHI,
L_UNIT2 LIKE T006-MSEHI,
L_OUTPUT TYPE P DECIMALS 3,
L_INPUT TYPE P DECIMALS 3.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
INPUT = L_INPUT "InputValue
UNIT_IN = L_UNIT1 "Unit need to be converted
UNIT_OUT = L_UNIT2 "Unit to be converted
IMPORTING
OUTPUT = L_OUTPUT "Value in required units
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.
V_QTY_FINAL = L_OUTPUT.
SHIFT V_QTY_FINAL LEFT DELETING LEADING SPACE.
ENDIF.
2) Use Function modules <b>CONVERT_TO_LOCAL_CURRENCY and CONVERT_TO_FOREIGN_CURRENCY</b> for currency conversions
Thanks,
Vinay
code to convert weight from one unit to another
FORM F_CONVERT_WEIGHT_INTO_KG USING P_WEIGHT
P_WT_UNIT.
DATA: LV_LB TYPE COMT_NET_WEIGHT,
LV_KG TYPE COMT_NET_WEIGHT,
LV_WT_UNIT TYPE COMT_UNIT.
LV_LB = P_WEIGHT.
LV_WT_UNIT = P_WT_UNIT.
CALL FUNCTION 'COM_PRODUCT_UNIT_CALC_WEIGHT'
EXPORTING
I_INPUT_B = LV_LB "your current MENGE
I_UNIT_B = LV_WT_UNIT "current MEINS
I_UNIT_A = 'KG' "target MEINS
I_NUMERATOR = 1
I_DENOMINATOR = 1
IMPORTING
E_OUTPUT_A = LV_KG. "weight in new MEINS
P_WEIGHT = LV_KG.
ENDFORM. " F_CONVERT_WEIGHT_INTO_KG
for currency conversions
use the function modules,
CONVERT_TO_FOREIGN_CURRENCY -
Convert Currency
CONVERT_TO_LOCAL_CURRENCY
CONVERT_COUNTRY_CURRENCY
CURRENCY_CONVERT
also refer this link,
Hai Kiran
Check the following Function Modules
For Unit
UNIT_OF_MEASURE_SAP_TO_ISO
UNIT_OF_MEASURE_ISO_TO_SAP
For Currency
CONVERT_TO_LOCAL_CURRENCY
CONVERT_COUNTRY_CURRENCY
CONVERT_TO_FOREIGN_CURRENCY
CURRENCY_CONVERT
Thanks & regards
Sreenivasulu P
Add comment