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: 

Round Off

Former Member
0 Kudos
118

Hi Experts,

I'm calculating the value & storing it in variable as LV_VAR. I would like to round off the value i.e. if LV_VAR = 0.265 then it should be 1.0, if 1.236 then it should be 2 like that.

Can anybody will suggest me how to do that?

Thanks,

Neha

10 REPLIES 10

former_member181962
Active Contributor
0 Kudos
89

use ceil function

data val type i.

val = ceil( lv_val ).

Regards,

Ravi

Former Member
0 Kudos
89

Hi Neha,

use the FM J_1I6_ROUND_TO_NEAREST_AMT

that pass your value to the I_AMOUNT you will get output in E_AMOUNT..

like that you have 5 fields you can use any of them in that FM.

Thanks

Former Member
0 Kudos
89

hello, Try this :


data : l_var type f.
l_var = '1.265'.
l_var = ceil( l_var ).

Former Member
0 Kudos
89

Hi,

U can define the Variable as integer or can use FM 'ROUND'. I hope this will solve your purpose.

Thanks

Amish.

0 Kudos
89

erm assigning 1,256 to an integer will give you 1 and not 2 like needed...

former_member226203
Active Contributor
0 Kudos
89

check this link which has the same requirement:

Former Member
0 Kudos
89

hi,

you can use FM 'ROUND'

0 Kudos
89

Hi,

Just use the following code in your program.

l_var = ceil( <calculation that you are doing> ).

and you will get the desired output

Former Member
0 Kudos
89

try the following code --

data: ft type f VALUE '1.23'.

DATA: i TYPE i.

i = CEIL( ft ).

WRITE / i.

0 Kudos
89

Hi,

use the statement 'ciel' it will work.

close the thread if you got ur solution.

regards,

jayaram