Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Random integer generator?

Former Member
0 Likes
1,189

Hi,

My requirement is to get a random integer between 0 and 100. I have been trying to use several different function modules (QF05_RANDOM_INTEGER, CACS_RANDOM_I4, etc.) to achieve this, but they are not random! They seem to always return the same number, when executed for the first time - for example CACS_RANDOM_I4 (with input 0 and 100) gives me always 4.

How to get a real random number.

Regards,

Pa

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
868

Try with the below function module:

GENERAL_GET_RANDOM_INT

******Reward points if useful

Regards,

Kiran Bobbala

5 REPLIES 5
Read only

Former Member
0 Likes
869

Try with the below function module:

GENERAL_GET_RANDOM_INT

******Reward points if useful

Regards,

Kiran Bobbala

Read only

0 Likes
868

Hi Kiran,

Your function module seem to solve the problem. At least it's more random than any of the function modules that I tried.

Read only

former_member195383
Active Contributor
0 Likes
868

use the FM NUMBER_GET_NEXT

It will give you the next number...

Reward points...if its useful...

Regards

Rudra

Regards

Rudra

Read only

Former Member
0 Likes
868

try these classes:

CL_ABAP_RANDOM and CL_ABAP_RANDOM_INT

Read only

Former Member
0 Likes
868

Hi!!

GENERAL_GET_RANDOM_INT

fuction module generates random numbers.Each time u execute some diffnt integer is generated.

Import parameters Value

RANGE 100

rewrd points.