Generate passwords programmatically with the desired characters (including special characters)

by Teja

In this article, we would look at a demo program, which generates a password programmatically with the desired alphabets, characters (both upper and lowercase) and special characters.

REPORT  zgenerate_pwd no standard page heading.
* Published for SAPTechnical.com
* Data declaration
DATA : w_password TYPE char10,    " Generated Password is stored here
       w_pass_chars(80).          " We provide the characters we desire 
                                  " in the password  
CONCATENATE
  'ABCDEFGHJKLMNPQRSTUVWXYZ'
  'abcdefghijklmnopqrstuvwxyz'
  '123456789@$%&/\()=+-#~ []{}'
  INTO w_pass_chars.
* Function module which generates the password
CALL FUNCTION 'RSEC_GENERATE_PASSWORD'
  EXPORTING
    alphabet             = w_pass_chars
    alphabet_length      = 0
    force_init           = ' '
    output_length        = 10
    downwards_compatible = ' '
  IMPORTING
    output               = w_password
  EXCEPTIONS
    some_error           = 1.
IF sy-subrc NE 0.
* Trigger some message, as required.
ENDIF.
WRITE:/ 'The generated password is: ', w_password.

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