Random Number Generation

by Sunitha

The function module, QF05_RANDOM_INTEGER, can be used to generate a random number. Sample program using the function module is shown below:

 REPORT zrandom_test.

DATA:
number TYPE i.

CALL FUNCTION 'QF05_RANDOM_INTEGER'
EXPORTING
  ran_int_max = 1000
  ran_int_min = 1
IMPORTING
  ran_int = number
EXCEPTIONS
  invalid_input = 1
  OTHERS = 2.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

WRITE :/ 'Next available number is: ', number.


 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image