看函数组:F052、QF05
例程1:
REPORT z_barry_random.
DATA: m type i ,
n(5) TYPE n.
n(5) TYPE n.
DO 20 TIMES.
CALL FUNCTION 'QF05_RANDOM_INTEGER'
EXPORTING
ran_int_max = 99999
ran_int_min = 10000
IMPORTING
ran_int = m
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
n = m.
WRITE:/ n.
ENDDO.
CALL FUNCTION 'QF05_RANDOM_INTEGER'
EXPORTING
ran_int_max = 99999
ran_int_min = 10000
IMPORTING
ran_int = m
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
n = m.
WRITE:/ n.
ENDDO.
----------------------------------
例程2:
DATA: cl_random TYPE REF TO cl_random_number,
m TYPE i.
m TYPE i.
START-OF-SELECTION.
CREATE OBJECT cl_random.
CALL METHOD cl_random->if_random_number~init .
CALL METHOD cl_random->if_random_number~get_random_int
EXPORTING
i_limit = 99999
RECEIVING
r_random = m.
CREATE OBJECT cl_random.
CALL METHOD cl_random->if_random_number~init .
CALL METHOD cl_random->if_random_number~get_random_int
EXPORTING
i_limit = 99999
RECEIVING
r_random = m.
WRITE m.