2008 Jun 23 11:59 AM
Hi,
Please tell me the syntax to round off the value.
eg: 95.5 to 96.
Thanks in advance,
Priya.
Hi,
Please tell me the syntax to round off the value.
eg: 95.5 to 96.
Thanks in advance,
Priya.
2008 Jun 23 11:59 AM
use ceil or floor commands
data: v_amt type p decimals 1 value '95.5',
v_amt = ceil( v_amt ).
v_amt = v_amt + 1.
write:/ v_amt.
2008 Jun 23 12:03 PM
use numeric type..it has the future to round off.....
Regards
Anbu
2008 Jun 23 12:03 PM
hi,
use these arthimetic operations.
CEIL
Smallest integer value that is not less than x
FLOOR
Largest integer value that is not greater than x
TRUNC
Interger part of x
FRAC
Decimal part of x
2008 Jun 23 12:03 PM
use like this:
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = 2
INPUT = temp_bvmtt
SIGN = 'X'
IMPORTING
OUTPUT = loc_bvmtt
EXCEPTIONS
INPUT_INVALID = 1
OVERFLOW = 2
TYPE_INVALID = 3
OTHERS = 4.Amit
2008 Jun 23 12:05 PM
Declare a variable of TYPE I and move the value into it. It automatically rounds up the value.
Regards,
Kiran
2008 Jun 23 12:10 PM
Hi,
Please refer the example below: (Extract from FM documentation)
DATA: VALUE TYPE F,
ROUND_VALUE TYPE F.
...
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = 2-
INPUT = VALUE
SIGN = '+'
IMPORTING
OUTPUT = ROUND_VALUE
EXCEPTIONS
INPUT_INVALD = 01
OVERFLOW = 02
TYPE_INVALID = 03.
This function module rounds the value INPUT to ANDEC decimal places. The parameter SIGN determines whether rounding is down ('-'), up ('+') or commercial ('X').
If SIGN = SPACE, there is no rounding (OUTPUT = INPUT).
Note
The result of floating point rounding calculations can be incorrect in certain cases because of rounding errors.
If INPUT is a field of type P, internal calculatons similarly use packed numbers. This is expensive, but more accurate. If the calculation accuracy is very important, INPUT should thus be a field of type P.
Thanks,
Sriram Ponna.