Application Development 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: 

Unit weight conversion LB to KG

Former Member
0 Kudos

Hi Guys,

I need to convert the LB to KG, i came to know this the FM "UNIT_CONVERSION_SIMPLE" will support,

I am pssing the INPUT = 100000

UNIT_IN = LB

UNIT_OUT = KG

But function module not giving any ouptut, Can any one suggest, what values i need to pass to the FM or any other way to do the conversion.

Thanks in advacne.

4 REPLIES 4

Former Member
0 Kudos

Hi,

CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

EXPORTING

input = slk-btgew " Weight in LB

unit_in = slk-gewei " LB

unit_out = vttkvb-dtmeg " KG

IMPORTING

output = slk-btgew. " Output : Weight in KG[/code]

Hope this helps,

Thanks,

Sree.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Make sure that your INPUT and OUTPUT parameters are typed correctly. This works for me.

data: lv_input type p DECIMALS 3 value '10000.000'.
data: lv_output type p DECIMALS 3.

CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
  EXPORTING
    input                      = lv_input
   UNIT_IN                    = 'LB'
   UNIT_OUT                   = 'KG'
 IMPORTING
   OUTPUT                     = lv_output
  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.

write:/ sy-subrc.
write:/ lv_output.

Regards,

Rich Heilman

david_carballido
Active Participant
0 Kudos

You can use the FM

CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
    EXPORTING
        input = g_weight_i
        unit_in = 'LB'
        unit_out = 'KG'
    IMPORTING
        output = g_weight_o.

Thanks and Regards

David Carballido

Former Member
0 Kudos

Hi,

Use it in your editor in SE38. I wont work in SE37.

data out type i.

CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

EXPORTING

input = 100000

UNIT_IN = 'LB'

UNIT_OUT = 'KG'

IMPORTING

OUTPUT = out

.

IF sy-subrc <> 0.

ENDIF.

write 😕 out.

Thanks,

Senthil