1、使用 function QF05_RANDOM_INTEGER 来获得随机数
CALL FUNCTION 'QF05_RANDOM_INTEGER' EXPORTING ran_int_max = 10 ran_int_min = 1 IMPORTING ran_int = my_value.
2、使用cl_random_number对象
DATA: cl_random TYPE REF TO cl_random_number, m TYPE i. 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.
3、使用cl_abap_random_int对象
DATA(r) = cl_abap_random_int=>create( seed = CONV i( sy-uzeit ) min = 1 max = 100 ). write / r->get_next( ).