ABAP Tutorial - How to Generate Random Number for a Given Range of Numbers using RANDOM_I2 Function Module
ABAP developers can generate random numbers for a given range of numbers using different methods.
In your SAP system, there may be more methods for ABAP random number generation.
You can run the SAP SE37 transaction code and search for "RANDOM*" for ready to use function modules in your ABAP codes in your current SAP system.
One function module used to generate random number is QF05_RANDOM_INTEGER.
Now in this ABAP tutorial, I want to give an ABAP example for generating random numbers using function module RANDOM_I2.
Below example ABAP codes and the sample call for ABAP function module can be seen in order to create random numbers.
The local variables lv_RangeMaximum and lv_RangeMinimum are in DATATYPE-INTEGER2 data type and the input parameters of function module RANDOM_I2.
These two parameters define the range of numbers by identifying the start and the end of the numbers range.
lv_RndI is used to get the output generated random number from the QF05_RANDOM_INTEGER function module.
And here is the output of the example ABAP code executed for 10 random random number generation.
The above example ABAP code can be used by ABAP developers in order to generate random number in ABAP.