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

Function Module to Convert distances

naresh_vvsr
Associate
Associate
0 Likes
3,431

Hello Experts,

Can you one suggest one Function module which can be used to convert distances in ABAP.

Example: Kilometers to Yards.

Regards,

Naresh

8 REPLIES 8
Read only

Former Member
0 Likes
2,264

You could achieve this by writing a couple of lines of code. Why do you need a Function Module?

pk

Read only

0 Likes
2,264

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 -

Read only

0 Likes
2,264

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

Read only

Former Member
0 Likes
2,264

Hi,

Check if these function modules are useful.

VHUMISC_CONVERT_TO_BASEUNIT

VHUMISC_CONVERT_TO_ALTERN_UNIT

Hope it helps.

Sujay

Read only

Former Member
0 Likes
2,264

Hi,

Us this FM : CONVERSION_FACTOR_GET

Regards,

Srini.

Read only

Former Member
0 Likes
2,264

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

Read only

Former Member
2,264

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

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,264

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