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

UNIT_CONVERSION_SIMPLE

Former Member
0 Likes
1,405

Hi. I am converting UOM from 'g' to 'lbs' and i'm using UNIT_CONVERSION_SIMPLE function module. My question is how will i make the output in 2 decimals places. I only got rounded off to the nearest whole number. Please help.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
681

Maybe this will help, all you need to do is pass fields that are TYPE p with Decimals places 2.



report zrich_0001.

data: out type p decimals 2.

parameters: p_in type p decimals 2 default '1234.67',
            p_uomi type t006-msehi default 'G' ,
            p_uomo type t006-msehi default 'LB'.

call function 'UNIT_CONVERSION_SIMPLE'
  exporting
    input                      = p_in
*   NO_TYPE_CHECK              = 'X'
*   ROUND_SIGN                 = ' '
   unit_in                    = p_uomi
   unit_out                   = p_uomo
 importing
*   ADD_CONST                  =
*   DECIMALS                   =
*   DENOMINATOR                =
*   NUMERATOR                  =
   output                     = out
* 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:/ out.

Regards,

Rich Heilman

1 REPLY 1
Read only

RichHeilman
Developer Advocate
Developer Advocate
682

Maybe this will help, all you need to do is pass fields that are TYPE p with Decimals places 2.



report zrich_0001.

data: out type p decimals 2.

parameters: p_in type p decimals 2 default '1234.67',
            p_uomi type t006-msehi default 'G' ,
            p_uomo type t006-msehi default 'LB'.

call function 'UNIT_CONVERSION_SIMPLE'
  exporting
    input                      = p_in
*   NO_TYPE_CHECK              = 'X'
*   ROUND_SIGN                 = ' '
   unit_in                    = p_uomi
   unit_out                   = p_uomo
 importing
*   ADD_CONST                  =
*   DECIMALS                   =
*   DENOMINATOR                =
*   NUMERATOR                  =
   output                     = out
* 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:/ out.

Regards,

Rich Heilman