This is a test message to test the length of the message box.
ABAP quick min-max values
Created by Software-Heroes

ABAP Quick - Min/max values of data types

Sometimes it is important to know the maximum limits of a data type before assigning a value to them. We show you today in our tip how it works.


In today's little tip we want to show you how to determine the minimum and maximum values of a data type. To this end, we want to make clear with a small example, with which simple code this is possible.



To do this, we define a number whose data type we want to analyze afterwards and a data reference which should receive the result.

  ld_number TYPE p LENGTH 16 DECIMALS 10,
  lr_result TYPE REF TO data.


Minimum value

Using class CL_ABAP_EXCEPTIONAL_VALUES, we can derive the minimum value and get back a data reference containing the minimum value. If the reference is set, we assign the value to a field symbol via inline declaration and pass the result to the demo output function.

lr_result = cl_abap_exceptional_values=>get_min_value( ld_number ).

IF lr_result IS NOT INITIAL.
  ASSIGN lr_result->* TO FIELD-SYMBOL(<ld_result>).
  cl_demo_output=>write_data( <ld_result> ).


Maximum value

To get the maximum value we use another method of the same class. Again we pass the value to the output method. Afterwards we show the result as a popup with the display method of the output class.

lr_result = cl_abap_exceptional_values=>get_max_value( ld_number ).

IF lr_result IS NOT INITIAL.
  ASSIGN lr_result->* TO FIELD-SYMBOL(<ld_result2>).
  cl_demo_output=>write_data( <ld_result2> ).

" Output
cl_demo_output=>display( ).



As you can see, finding the minimum and maximum value of a data type is not difficult. The class contains additional functions to validate other data types. Just try it out and get acquainted with it to use it effectively for dynamic programming.

Included topics:
Comments (0)

ABAP Quick - Wait for task

Category - ABAP

Today a tip for asynchronous processing or if you want to put processing in a separate task in special situations. What happens afterwards?


ABAP Quick - Performance INSERT vs VALUE

Category - ABAP

In this article we take a look at the performance of the insert operations APPEND, INSERT and VALUE with regard to tables and evaluate the performance and stability during development.


ABAP - BOPF Quick Guide (Update)

Category - ABAP

A little update to our book that we published. For all people who find the paperless office boring.


ABAP - BOPF Quick Guide

Category - ABAP

You need a quick introduction to the SAP Business Object Processing Framework (BOPF), we have the right guide for you here.


ABAP Quick - Search in source code

Category - ABAP

Sometimes it is necessary to search through different source codes in one system. We show you how it works in the SAP GUI and in Eclipse.


We use cookies for our services and functions. More informations