01-21-2008 12:28 PM
i declared variable as ZFOR1 TYPE EKET-MENGE.i want to round off the value to the next integer.if i get the value as
2.14 or 2.64 it should be rounded to 3.if i declare it as integer it is getting rounded to nearest integer that is 2.14 to 2 and 2.64 to 3.but i want both to 3.please help.
01-21-2008 12:31 PM
Hi,
Please refer to the below code :
Hi,
Use ceil( ) function.
Ex. a = ceil ( 398.98).
wreite:/ a.
Regards,
Subha.
Similarly floor ( ) function also,
Thanks,
Sriram POnna.
01-21-2008 12:31 PM
Hi,
Please refer to the below code :
Hi,
Use ceil( ) function.
Ex. a = ceil ( 398.98).
wreite:/ a.
Regards,
Subha.
Similarly floor ( ) function also,
Thanks,
Sriram POnna.
01-21-2008 12:37 PM
01-21-2008 12:53 PM
parameters: num1(5) type p decimals 2.
data: num2(5) type p decimals 2.
num2 = ceil( num1 ).
write:/ num2.
01-21-2008 12:32 PM
01-21-2008 12:35 PM
Hello,
This is waht you want.
DATA: WA_INPUT TYPE P DECIMALS 2,
WA_OUTPUT TYPE I."P DECIMALS 2.
DATA: STR(10),STR1(10),STR2(10).
WA_INPUT = '2.14'.
WRITE WA_INPUT TO STR.
SPLIT STR AT ',' INTO STR1 STR2.
ADD 1 TO STR1.
WRITE STR1." TO WA_INPUT.
Cheers,
Vasanth
01-21-2008 12:38 PM
Hello,
Try this also.
DATA: WA_INPUT TYPE P DECIMALS 2,
WA_OUTPUT TYPE I."P DECIMALS 2.
DATA: STR(10),STR1(10),STR2(10).
WA_INPUT = '2.64'.
STR1 = CEIL( WA_INPUT ).
WRITE STR1.
Cheers,
Vasanth
01-21-2008 12:53 PM
data: n1 type p decimals 2,
n2 type p decimals 2,
f type p decimals 2.
n1 = '10.3'.
f = frac( n1 ).
if f >= '0.5'.
n1 = n1 + ( 1 - f ).
else.
n1 = n1 - f.
endif.
write n1.
n2 = '10.7'.
f = frac( n2 ).
if f >= '0.5'.
n2 = n2 + ( 1 - f ).
else.
n2 = n2 - f.
endif.
write n2.