Округление чисел CALL FUNCTION ‘ROUND’

Functionality
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).
Example
The value VALUE is to be rounded up to the nearest hundred.

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.

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 thecalculation accuracy is very important, INPUT should thus be a field oftype P.

 

      • Negative values are also allowed here:

 

      • For positive values count to the right from the decimal point, fornegative values, to the left.

 

      • E.g.: 1234,1234 rounded to -2 decimal places equals 1200

 

      • 1234,1234 rounded to 2 decimal places equals 1234,12

 

      • SPACE,,: no rounding (input = output)

 

      • ‘+’,,: round up

 

      • ‘-‘,,: round down

 

    • ‘X’,,: commercial rounding

 

Добавить комментарий