‎2007 Jan 02 8:30 AM
Hi all,
I am making some division as follows.
data: a type p decimals 2,
b(2) type c,
a = ( 62 / 13 ).
write a decimals 0 to b.
b = b + 1.
It returns the value 4.77 to a
while adding it gets rounded off to 5 and then further addition is done.
But as per my requirement, I want only the value 4 irrespective of decimals i.e. the result without rounded off .
Pls. help me.
Thanks in advance.
‎2007 Jan 02 8:35 AM
Hi,
data: a type p decimals 2,
b(2) type c,
a = ( 62 / 13 ).
a = trunc( a ).
‎2007 Jan 02 8:35 AM
Hi Shravani,
Then you can go with statement called FLOOR , It will help you.
Reward point if it is helpful
Regards,
Kiran I
‎2007 Jan 02 8:35 AM
Hi,
please use a= (62 DIV 14) to receive the value.
See transaction abapterm search word DIV for further details.
DIV is an arithmetic operand in sap.
Hth
Ute
‎2007 Jan 02 8:37 AM
Hi,
U can use <b>floor</b> function as given below.
FLOOR( X ) :
Largest integer value that is not greater than x
data: a type p decimals 2,
b(2) type c.
a = ( 62 / 13 ).
b = floor( a ).
write b.
‎2007 Jan 02 8:37 AM
Hi Shravani ,
Use the command FLOOR.
Here is the modified code
data: a type p decimals 2,
b(2) type c.
a = ( 62 / 13 ).
a = FLOOR( a ). " Code Added
write a decimals 0 to b.
b = b + 1.
write: b.Regards
Arun
Assign Points for helpful reply
‎2007 Jan 02 8:37 AM
use as ur requerment for rounding..
check this example...
DATA: I TYPE I,
P TYPE P DECIMALS 2,
M TYPE F VALUE '-3.5',
D TYPE P DECIMALS 1.
P = ABS( M ). " 3,5
I = P. " 4 - business rounding
I = M. " -4
I = CEIL( P ). " 4 - next largest whole number
I = CEIL( M ). " -3
I = FLOOR( P ). " 3 - next smallest whole number
I = FLOOR( M ). " -4
I = TRUNC( P ). " 3 - integer part
I = TRUNC( M ). " -3
D = FRAC( P ). " 0.5 - decimal part
D = FRAC( M ). " -0.5
‎2007 Jan 02 8:40 AM
Hi Shrawani,
see below code.
DATA: a TYPE p DECIMALS 2,
b(2) TYPE c.
a = ( 62 / 13 ).
a = TRUNC( a ).
WRITE a DECIMALS 0 TO b.
b = b + 1.
it will work.
Regards
Ashutosh
Reward points if helpful
‎2007 Jan 02 8:41 AM
use the fn FLOOR
data i type i.
data p type p decimals 2 value '3.7'.
compute i = FLOOR( p ).
now i contains 3 now.
regards
shiba dutta
‎2007 Jan 02 8:45 AM