ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Numeric Calculations → Numerical Functions → Examples of numerical functions
Rounding Function: Round
This example demonstrates the following 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 und -1, the program depicts the effect of all rounding types from the CL_ABAP_MATH class in a classic list. The program reads the possible rounding types using the RTTI and sorts them by name.