‎2007 Nov 02 4:30 AM
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
‎2007 Nov 02 4:35 AM
Hi,
You can use Func MOdule ROUND. or also can use abap statments CEIL or FLOOR. for rounding your integer value.
regards,
paras
‎2007 Nov 02 4:33 AM
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
‎2007 Nov 02 5:16 AM
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.
‎2007 Nov 02 6:15 AM
Type P will automaticly rounding off your value depend on decimals you put on it.
‎2007 Nov 02 4:35 AM
Hi,
You can use Func MOdule ROUND. or also can use abap statments CEIL or FLOOR. for rounding your integer value.
regards,
paras
‎2007 Nov 02 4:36 AM
‎2007 Nov 02 4:44 AM
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
‎2007 Nov 02 4:53 AM
‎2007 Nov 02 6:52 AM
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