Skip to content

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

Extremum functions nmax, nmin

The example demonstrates the extremum functions nmax and nmin.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    CONSTANTS: xmin TYPE i VALUE -100,
               xmax TYPE i VALUE 100,
               n    TYPE i VALUE 20000.
    DATA:      x    TYPE decfloat34,
               y    TYPE decfloat34,
               y0   TYPE decfloat34.
    DATA       txt  TYPE string.

    DO n + 1 TIMES.
      x = ( xmax - xmin ) / n * ( sy-index - 1 ) + xmin.
      y = a * x ** 2 + b * x + c.
      IF sy-index = 1.
        y0 = y.
      ELSE.
        IF a > 0.
          txt = 'Minimum'.
          y0 = nmin( val1 = y0 val2 = y ).
        ELSE.
          txt = 'Maximum'.
          y0 = nmax( val1 = y0 val2 = y ).
        ENDIF.
      ENDIF.
    ENDDO.
    txt = |{ txt } value of parabola is: { y0 }|.
    MESSAGE txt TYPE 'I'.

Description

The program determines the minimum or maximum value of a parabola which is opened upward or downward and whose parameters can be input on the selection screen.