SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Numeric Calculations → Numerical Functions → Examples of numerical functions →Numerical Functions
This example demonstrates the use of general numerical functions.
Source Code
REPORT demo_numerical_function.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
DATA n TYPE decfloat16.
DATA m TYPE decfloat16 VALUE '-5.55'.
DATA(out) = cl_demo_output=>new( ).
n = abs( m ).
out->write( |ABS: { n }| ).
n = sign( m ).
out->write( |SIGN: { n }| ).
n = ceil( m ).
out->write( |CEIL: { n }| ).
n = floor( m ).
out->write( |FLOOR: { n }| ).
n = trunc( m ).
out->write( |TRUNC: { n }| ).
n = frac( m ).
out->write( |FRAC: { n }| ).
out->display( ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
Description
The output of the program shows how each of the general numerical functions affects the number -5.55.