Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Numeric Calculations →  Numerical Functions →  Examples of numerical functions 

Rounding Function round

This example demonstrates the rounding function round.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA number TYPE decfloat34.
    cl_demo_output=>begin_section( `Rounding Function` ).
    get_modes( ).
    DO 21 TIMES.
      number = - ( sy-index - 11 ) / 10.
      write_output(
        idx = sy-index
        col = '1'
        text = |{ number }| ).
      LOOP AT modes INTO mode.
        write_output(
          idx = sy-index
          col = sy-tabix + 1
          text = |{ round( val  = number
                           dec  = 0
                           mode = mode-value ) }| ).
      ENDLOOP.
    ENDDO.
    cl_demo_output=>display( output ).

Description

For fraction numbers between 1 and -1, the program depicts the effect of all rounding types from the class CL_ABAP_MATH in the rounding function round. The program reads the possible rounding methods using RTTI and sorts them by name.