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

Func Module required

Former Member
0 Likes
1,010

Hi

I have to round off the interger value to the nearest interger value,so please if there exit any FM for this pass me the name,or the logic I have to put there for this.Moreover I alos have to check if the integer value is coming out to be -ive ,i have to take it as 0.

so plz tell me the way to do this.

Regards

vipin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
991

Hi,

You can use Func MOdule ROUND. or also can use abap statments CEIL or FLOOR. for rounding your integer value.

regards,

paras

8 REPLIES 8
Read only

Former Member
0 Likes
991

Hi,

Try this..

data: v_amount type netpr value '123.46'.

data: v_mod type i.

v_amount = v_amount * 100.

v_mod = v_amount mod 100.

v_amount = v_amount / 100.

if v_mod > 50.

  • Use the ceil function to round it up.

v_amount = ceil( v_amount ).

write: / v_amount.

else.

  • Use the floor function to round it down.

v_amount = floor( v_amount ).

write: / v_amount.

endif.

Thanks

Naren

Read only

0 Likes
991

there is an variable,data : l type p decimal 2.

l = l + 481/4 = 120.25.

when i am using l type p decimal 2.its displaying l = 120.25,if just l type p its displaying 120.

i want ask whether this p type is automatilacly rounding off or will do some problem later on.

or i have to use some FM for rounding off.

Read only

0 Likes
991

Type P will automaticly rounding off your value depend on decimals you put on it.

Read only

Former Member
0 Likes
993

Hi,

You can use Func MOdule ROUND. or also can use abap statments CEIL or FLOOR. for rounding your integer value.

regards,

paras

Read only

former_member194152
Contributor
0 Likes
991

Hi,

for rounding off to integer no function module is required you directly assign floai varriable to integer varriable it will internally conver and round the value.

Regards

Gagan

Read only

Former Member
0 Likes
991

Hi

use this function module

ROUND_AMOUNT

Read only

Former Member
0 Likes
991

HI

Check this

DATA n TYPE p DECIMALS 2.

DATA m TYPE p DECIMALS 2 VALUE '-5.55'.

n = abs( m ). WRITE: 'ABS: ', n.

n = sign( m ). WRITE: / 'SIGN: ', n.

n = ceil( m ). WRITE: / 'CEIL: ', n.

n = floor( m ). WRITE: / 'FLOOR:', n.

n = trunc( m ). WRITE: / 'TRUNC:', n.

n = frac( m ). WRITE: / 'FRAC: ', n.

ULINE.

  • floating points

DATA: result TYPE f,

pi(10) TYPE c VALUE '3.14159265'.

result = cos( pi ).

WRITE result.

Praveen