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

how to round of values using Round Function

Former Member
0 Likes
22,407

Hi All,

i have made a WIHTHOLDING TAX REPORT in which there's a filed of tax rate in percent.The issue is that *tax rate * field given me point values which i want to be round off,for example:

TAX RATE is giving value of 5.9979 and i want it to be round off.It should be 6.Another example is if

TAX RATE is giving value of 3.3982 and i want it to be round off.It should be 3.3.

Another thing is that *TAX RATE * filed is giving 4 digit after point but i want it

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
8,986

Hi ..

I found one statement in order to work with this round function.It is really simple..

Have a try and let me know.......

Example is given below.........

DATA pack TYPE p VALUE '123.456'

DECIMALS 3.

WRITE pack DECIMALS 2.

WRITE: / pack ROUND -2,

/ pack ROUND -1,

/ pack ROUND 1,

/ pack ROUND 2.

6 REPLIES 6
Read only

Former Member
0 Likes
8,986

Hi,

look here:

Regards, Dieter

Read only

former_member214857
Contributor
0 Likes
8,986

Hi

You can use function module ROUND

CALL FUNCTION 'ROUND'
       EXPORTING
            DECIMALS      = ANDEC
            INPUT         = VI_F
            SIGN          = RT
       IMPORTING
            OUTPUT        = VO_F
       EXCEPTIONS
            INPUT_INVALID = 1
            OVERFLOW      = 2
            TYPE_INVALID  = 3
            OTHERS        = 4.

Edited by: Carlos Machado on May 31, 2010 11:52 PM

Read only

0 Likes
8,986

@modos,

i request you to allow or direct people to search these questions.. hope you will agree with me..

Read only

Former Member
0 Likes
8,987

Hi ..

I found one statement in order to work with this round function.It is really simple..

Have a try and let me know.......

Example is given below.........

DATA pack TYPE p VALUE '123.456'

DECIMALS 3.

WRITE pack DECIMALS 2.

WRITE: / pack ROUND -2,

/ pack ROUND -1,

/ pack ROUND 1,

/ pack ROUND 2.

Read only

0 Likes
8,986

Rounding a value using 'FM'

data: num(10) type p decimals 4.

data: num1(5) type p decimals 2.

num = '4.017'.

CALL FUNCTION 'ROUND'

EXPORTING

DECIMALS = 2

INPUT = num

  • SIGN = ' '

IMPORTING

OUTPUT = num1

  • EXCEPTIONS

  • NPUT_INVALID = 1

  • OVERFLOW = 2

*TYPE_INVALID = 3

  • OTHERS = 4

.

U could have try this to resove this query.

Please let me know.

Good Luck..

Read only

Former Member
0 Likes
8,986

Hi,

You can use the CEIL function..

Ex..

v_ouput = CEIL( tax_rate ).

write: / v_output.

that is the most easy.