‎2010 Aug 30 11:16 AM
Hello Experts,
Can you one suggest one Function module which can be used to convert distances in ABAP.
Example: Kilometers to Yards.
Regards,
Naresh
‎2010 Aug 30 11:19 AM
You could achieve this by writing a couple of lines of code. Why do you need a Function Module?
pk
‎2010 Aug 30 11:27 AM
Hi,
We actually have many units to convert from one to another. So we wanted any existing generic distance converting FM to achive the purpose.
Example Units for conversion are,
CM - Centimeter
DM - Decimeter
Foot -
Kilometer -
Meter -
Mile -
Millimeter -
Nanometer -
Yards -
Micrometer -
‎2010 Aug 30 11:41 AM
Hi PK,
It's way easier to explain to some users "it's the way SAP does it" than to try to explain them how their custom logic makes no sense
‎2010 Aug 30 11:41 AM
Hi,
Check if these function modules are useful.
VHUMISC_CONVERT_TO_BASEUNIT
VHUMISC_CONVERT_TO_ALTERN_UNIT
Hope it helps.
Sujay
‎2010 Aug 30 11:52 AM
‎2010 Aug 30 12:21 PM
I've not used any such Function Modules till date. But knowing SAP's penchant for FMs you will find scores of them, if you search.
FIrstly, you could use the generic way of searching - Google search, SCN search etc.
Secondly, you could search through SAP - put search terms *CONVERT* or *CONVERSION* etc in SE37 and press F4.
pk
‎2010 Aug 30 1:11 PM
Hi,
Use the function module UNIT_CONVERSION_SIMPLE for conversion from one unit to another like KM to YD.
For example the below code shows conversion from Kilometers to Yards.
DATA: out TYPE p.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
input = 10
* NO_TYPE_CHECK = 'X'
* ROUND_SIGN = ' '
unit_in = 'KM' (For Kilometers)
unit_out = 'YD' (To Yardss)
IMPORTING
* ADD_CONST =
* DECIMALS =
* DENOMINATOR =
* NUMERATOR =
output = out.
The output is stored in the variable out.
And for remaining unit conversions check T006-MSEHI value You will able to know remaining units.
Edited by: phani marella on Aug 30, 2010 2:56 PM
Edited by: phani marella on Aug 31, 2010 5:22 AM
‎2010 Aug 30 1:50 PM
SAP has provided a lot of FM for that, check [Measurement unit conversion|http://help.sap.com/saphelp_bw/helpdata/en/2a/fa013c493111d182b70000e829fbfe/content.htm] in [BC Extended Applications Function Library|http://help.sap.com/saphelp_bw/helpdata/en/2a/f9ff44493111d182b70000e829fbfe/frameset.htm] (useful links if you don't master F4 on SE37 )
Regards,
Raymond