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: 

Rounding a value

former_member202474
Contributor
0 Kudos

Hi ,

I have a requirement to round of the value 600.00, to 600.But if the variable contains 600.50, then the value should not change ,it should remain as it is.Only if the value after the decimal point is initial , then it should round off.

Is there any function module or command to do this?? I dont want to use split statement.Please guide.

Thanks,

Ruby.

8 REPLIES 8

Former Member
0 Kudos

Hi

Try with these commands for rounding a value

ceil :Smallest integer number that is not smaller than the value of the argument arg.

floor :Largest integer number that is not larger than the value of the argument arg.

Thnx

Sravani

Plz rewrd points......

Former Member
0 Kudos

hi check this..

data: nu(10) type p decimals 4.

data: nu1(5) type p decimals 2.

nu = '4.017'.

CALL FUNCTION 'ROUND'

EXPORTING

DECIMALS = 2

INPUT = nu

  • SIGN = ' '

IMPORTING

OUTPUT = nu1

  • EXCEPTIONS

  • NPUT_INVALID = 1

  • OVERFLOW = 2

*TYPE_INVALID = 3

  • OTHERS = 4

regards,

venkat

former_member202474
Contributor
0 Kudos

Hi,

I tried using this already, but it doenst work.

0 Kudos

Chacko,

You need to change the datatype to get it printed as 600,as long as the datatype is curr it will print as 600.00.

600.00 itself means rounded off,so the problem is not to round off but only to print without decimals when it is 600.00 and with decimals when it is 600.50

use offset and move 600 to a different variable when 600.00,when 600.50 print it as it is.

data: temp1 like bseg-wrbtr value '600',

temp2 like bseg-wrbtr value '600.00',

temp3 like bseg-wrbtr value '600.50',

temp4(15) type c,

temp5(13) type c,

temp6(2) type c.

move temp3 to temp4.

split temp4 at '.' into temp5 temp6.

if temp6 = '00'.

write:/ 'without decimals-', temp5.

else.

write:/ 'with decimals-',temp3.

endif.

K.Kiran.

Former Member
0 Kudos

try to split the value into two variables ...

data : v_data(20).

v_data = '600.00'.

split v_data at '.' into v_data1 v_data2.

if v_data2 is initial.

*use v_data1.

else.

*use v_data.

endif.

former_member202474
Contributor
0 Kudos

Hi,

So is there no other options, other than using split statement?

0 Kudos

Chacko,

With type P we can't use offset,so I guess split is the way to achieve this.

K.Kiran.

Former Member
0 Kudos

Hi,

USE THE BELOW MENTIONED FM

J_1I6_ROUND_TO_NEAREST_AMT

Note; Please reward points, if found suitable.

Regards,

IFF