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

Round Off

Former Member
0 Likes
1,326

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

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
Read only

Former Member
0 Likes
1,297

use ceil function

data val type i.

val = ceil( lv_val ).

Regards,

Ravi

Read only

Former Member
0 Likes
1,297

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

Read only

Former Member
0 Likes
1,297

hello, Try this :


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

Read only

Former Member
0 Likes
1,297

Hi,

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

Thanks

Amish.

Read only

0 Likes
1,297

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

Read only

Former Member
0 Likes
1,297

check this link which has the same requirement:

Read only

Former Member
0 Likes
1,297

hi,

you can use FM 'ROUND'

Read only

0 Likes
1,297

Hi,

Just use the following code in your program.

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

and you will get the desired output

Read only

Former Member
0 Likes
1,297

try the following code --

data: ft type f VALUE '1.23'.

DATA: i TYPE i.

i = CEIL( ft ).

WRITE / i.

Read only

0 Likes
1,297

Hi,

use the statement 'ciel' it will work.

close the thread if you got ur solution.

regards,

jayaram