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

Evenly distributed non-reproducible random integer sequence

Former Member
0 Likes
501

Is there a class for producing a sequence of evenly distributed non-reproducible random integers? I'm on a 7.00 system.

-- Sebastian

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
460

If looking for FM then 'QF05_RANDOM_INTEGER'

2 REPLIES 2
Read only

Former Member
0 Likes
461

If looking for FM then 'QF05_RANDOM_INTEGER'

Read only

Former Member
0 Likes
460

The answer is yes:


  DATA:
    lv_seed TYPE i,
    lo_prng TYPE REF TO cl_abap_random_int,
    lv_rnd TYPE i.

  " Get a random seed to make the sequence non-reproducible
  lv_seed = cl_abap_random=>seed( ).

  " compute evenly distributed pseudo random numbers in the interval [0,100]
  lo_prng = cl_abap_random_int=>create( seed = lv_seed min = 0 max = 100 ).

  DO c_limit TIMES.

    lv_rnd  = lo_prng->get_next( ).

    WRITE: / lv_rnd.

  ENDDO.

Sorry for posting prematurely.

-- Sebastian