Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Numeric Calculations →  System Classes for Numbers 

Random Numbers

The class CL_ABAP_RANDOM calls the pseudo random number generator Mersenne Twister for different numeric types.

For the one-dimensional case, the following special classes generate random numbers for the different numeric types:

  • CL_ABAP_RANDOM_INT for type i
  • CL_ABAP_RANDOM_INT8 for type int8
  • CL_ABAP_RANDOM_FLOAT für Typ f
  • CL_ABAP_RANDOM_PACKED for type p
  • CL_ABAP_RANDOM_PACKED_DEC1 to CL_ABAP_RANDOM_PACKED_DEC14 für Typ p with 1 to 14 decimal places.
  • CL_ABAP_RANDOM_DECFLOAT16 for type decfloat16
  • CL_ABAP_RANDOM_DECFLOAT34 for type decfloat34

Other versions: 7.31 | 7.40 | 7.54


Example

Creates a pseudo random number of the type i between 1 and 100 (initialized by the system time).

DATA(r) = cl_abap_random_int=>create( seed = CONV i( sy-uzeit ) 
                                    min  = 1 
                                     max  = 100 ).