第一种:随机数字字符串
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 = 9999999
RECEIVING
r_random = m.
第二种:随机大小字母字符串
DATA:snum TYPE string.
CALL FUNCTION 'GENERAL_GET_RANDOM_STRING'
EXPORTING
number_chars = '40'
IMPORTING
random_string = snum.
第三种:指定字符串集,生成随机字符串
DATA: l_no(40) TYPE c,
l_index TYPE i,
albet(80).
CLEAR:l_no,l_index.
CONCATENATE 'ABCDEFGHJKLMNPQRSTUVWXYZ'
'abcdefghijklmnopqrstuvwxyz'
'123456789~!#$%^&*()[]/\{}'
INTO albet.
CALL FUNCTION 'RSEC_GENERATE_PASSWORD'
EXPORTING
alphabet = albet
output_length = 40
IMPORTING
output = l_no
EXCEPTIONS
some_error = 1.
执行效果: