SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Numeric Calculations → arith_exp - Arithmetic Expressions → arith_exp - Arithmetic Operators →Arithmetic Calculations
This example demonstrates the use of different divisions.
Source Code
REPORT demo_data_calculate.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
DATA: pack TYPE p DECIMALS 4,
n TYPE decfloat16 VALUE '+5.2',
m TYPE decfloat16 VALUE '+1.1'.
pack = n / m.
cl_demo_output=>write( |{ n } / { m } = { pack }| ).
pack = n DIV m.
cl_demo_output=>write( |{ n } DIV { m } = { pack }| ).
pack = n MOD m.
cl_demo_output=>display( |{ n } MOD { m } = { pack }| ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
Description
In this example, the functions of the three division operators, DIV, MOD, and / are demonstrated.