The function module RSEC_GENERATE_PASSWORD is used to generate a random SAP password, similar to that you recieve when you create a new user via transaction SU01.
DATA g_password1 LIKE xu400-newcode. DATA: g_downward_comp. CALL FUNCTION 'RSEC_GENERATE_PASSWORD' EXPORTING alphabet = space "Use default downwards_compatible = g_downward_comp "left blank IMPORTING output = g_password1 EXCEPTIONS some_error = 1 OTHERS = 2.