Brute force User Maintenance (Program)

For detailed procedure on Brute force maintenance, click here.

*&---------------------------------------------------------------------*
*& Report  ZGB_PROG01
*&
*&---------------------------------------------------------------------*
*& This program resets is primarily for BASIS guys who require
*& advanced user administration not provided by SAP.
*&---------------------------------------------------------------------*
*                                                                      *
*                                                                      *
************************************************************************
* Programmer        : GBANERJI                                         *
************************************************************************
* Maintenance Log                                                      *
*----------------------------------------------------------------------*
* Changed By      Date         Transport#   Description                *
*------------ ---------------------------------------------------------*
* GBANERJI        --/--/--     **********   Changed program to avoid   *
*----------------------------------------------------------------------*
REPORT  zgb_prog01 LINE-SIZE 120
        NO STANDARD PAGE HEADING.
************************************************************************
*                  D-A-T-A  D-E-F-I-N-I-T-I-O-N-S                      *
************************************************************************
**************DEFINITION OF INTERNAL TABLE STRUCTURES*******************
TYPES: BEGIN OF ty_users,
         bname TYPE usr02-bname,
       END OF ty_users.
************************************************************************
*                 D-A-T-A  D-E-C-L-A-R-A-T-I-O-N-S                     *
************************************************************************
**********************DECLARATION OF TYPE POOLS*************************
TYPE-POOLS: vrm.
*******************DECLARATION OF INTERNAL TABLES***********************
DATA: it_users TYPE TABLE OF ty_users WITH HEADER LINE.
DATA: it_usr02 TYPE TABLE OF usr02 WITH HEADER LINE.
*FIELDNAME AND TAB NAME FOR THE SELECTION
DATA :field_tab LIKE dfies  OCCURS 0 WITH HEADER LINE.
*THE TABLE FOR RETURNING THE NAME OF THE SELECTED ITEM
DATA : return_tab LIKE ddshretval OCCURS 0 WITH HEADER LINE.
**********************DECLARATION OF WORK AREA**************************
DATA: bname TYPE usr02-bname,
      newcode TYPE xu400-newcode.
DATA: list  TYPE vrm_values,
      wa_list TYPE vrm_value,
      c_mandt TYPE t000-mandt.
DATA: dest  TYPE vrm_values,
      wa_dest TYPE vrm_value,
      c_dests TYPE t000-mandt.
DATA: wa_usr02 TYPE usr02.
************************************************************************
*                   I-N-I-T-I-A-L-I-Z-A-T-I-O-N                        *
************************************************************************
INITIALIZATION.
  PERFORM update_client_list.
  PERFORM update_user_list.
************************************************************************
*                  S-E-L-E-C-T-I-O-N  S-C-R-E-E-N                      *
************************************************************************
*---------------------------------------------------------------------*
*   Tab Strips 1
*---------------------------------------------------------------------*
  SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN.
  SELECTION-SCREEN BEGIN OF BLOCK data1 WITH FRAME TITLE block1.
  PARAMETERS: p_ustyp LIKE usr02-ustyp.
  PARAMETERS: p_class LIKE usr02-class.
  SELECTION-SCREEN END OF BLOCK data1.
  SELECTION-SCREEN END OF SCREEN 101.
*---------------------------------------------------------------------*
*   Tab Strips 2
*---------------------------------------------------------------------*
  SELECTION-SCREEN BEGIN OF SCREEN 102 AS SUBSCREEN.
  SELECTION-SCREEN BEGIN OF BLOCK data2 WITH FRAME TITLE block2.
  PARAMETERS: p_uflag LIKE usr02-uflag.
  SELECTION-SCREEN PUSHBUTTON /33(20) btn_pass USER-COMMAND unlock.
  SELECTION-SCREEN END OF BLOCK data2.
  SELECTION-SCREEN END OF SCREEN 102.
*---------------------------------------------------------------------*
*   Tab Strips 3
*---------------------------------------------------------------------*
  SELECTION-SCREEN BEGIN OF SCREEN 103 AS SUBSCREEN.
  SELECTION-SCREEN BEGIN OF BLOCK data3 WITH FRAME TITLE block3.
  PARAMETERS: p_slicno TYPE slic_inst.
  PARAMETERS: p_devkey LIKE devaccess-accesskey.
  SELECTION-SCREEN PUSHBUTTON /33(20) btn_keyr USER-COMMAND remkey.
  SELECTION-SCREEN PUSHBUTTON /33(20) btn_keya USER-COMMAND addkey.
  SELECTION-SCREEN END OF BLOCK data3.
  SELECTION-SCREEN END OF SCREEN 103.
*---------------------------------------------------------------------*
*   Tab Strips 4
*---------------------------------------------------------------------*
  SELECTION-SCREEN BEGIN OF SCREEN 104 AS SUBSCREEN.
  SELECTION-SCREEN BEGIN OF BLOCK data4 WITH FRAME TITLE block4.
  SELECTION-SCREEN COMMENT 01(40) com104.
  SELECTION-SCREEN COMMENT /01(40) com104a.
  SELECTION-SCREEN PUSHBUTTON /33(25) btn_chis USER-COMMAND clr_hist.
  SELECTION-SCREEN END OF BLOCK data4.
  SELECTION-SCREEN END OF SCREEN 104.
*---------------------------------------------------------------------*
*   Tab Strips 5
*---------------------------------------------------------------------*
  SELECTION-SCREEN BEGIN OF SCREEN 105 AS SUBSCREEN.
  SELECTION-SCREEN BEGIN OF BLOCK data5 WITH FRAME TITLE block5.
  SELECTION-SCREEN COMMENT 01(77) com105.
  SELECTION-SCREEN COMMENT /01(77) com105a.
  PARAMETERS: p_bcode LIKE usr02-bcode.
  PARAMETERS: p_dests LIKE t000-mandt AS LISTBOX VISIBLE LENGTH 10 DEFAULT sy-mandt OBLIGATORY USER-COMMAND ucom1.
  SELECTION-SCREEN PUSHBUTTON /33(25) btn_cpyh USER-COMMAND cpy_hash.
  SELECTION-SCREEN END OF BLOCK data5.
  SELECTION-SCREEN END OF SCREEN 105.
*---------------------------------------------------------------------*
*   Tab Strips 6
*---------------------------------------------------------------------*
  SELECTION-SCREEN BEGIN OF SCREEN 106 AS SUBSCREEN.
  SELECTION-SCREEN BEGIN OF BLOCK data6 WITH FRAME TITLE block6.
  SELECTION-SCREEN COMMENT 01(77) com106.
  SELECTION-SCREEN COMMENT /01(77) com106a.
  PARAMETERS: p_GLTGV LIKE usr02-GLTGV.
  PARAMETERS: p_GLTGB LIKE usr02-GLTGB.
  SELECTION-SCREEN PUSHBUTTON /33(20) btn_vald USER-COMMAND resdat.
  SELECTION-SCREEN END OF BLOCK data6.
  SELECTION-SCREEN END OF SCREEN 106.
******************** START OF SCREEN 1000******************************
  SELECTION-SCREEN COMMENT 01(40) com1000.
  PARAMETERS: p_mandt LIKE t000-mandt AS LISTBOX VISIBLE LENGTH 10 DEFAULT sy-mandt OBLIGATORY USER-COMMAND ucom.
  PARAMETERS: p_bname LIKE usr02-bname.
  SELECTION-SCREEN BEGIN OF TABBED BLOCK uno FOR 10 LINES.
  SELECTION-SCREEN TAB (20) name1 USER-COMMAND ucomm1
  DEFAULT SCREEN 101.
  SELECTION-SCREEN TAB (20) name2 USER-COMMAND ucomm2
  DEFAULT SCREEN 102.
  SELECTION-SCREEN TAB (20) name3 USER-COMMAND ucomm3
  DEFAULT SCREEN 103.
  SELECTION-SCREEN TAB (20) name4 USER-COMMAND ucomm4
  DEFAULT SCREEN 104.
  SELECTION-SCREEN TAB (20) name5 USER-COMMAND ucomm5
  DEFAULT SCREEN 105.
  SELECTION-SCREEN TAB (20) name6 USER-COMMAND ucomm6
  DEFAULT SCREEN 106.
  SELECTION-SCREEN END OF BLOCK uno.
*NAMING THE TABS
  MOVE 'User Data' TO name1.
  MOVE 'Lock Status' TO name2.
  MOVE 'Dev Key' TO name3.
  MOVE 'Password History' TO name4.
  MOVE 'Password Hash' TO name5.
  MOVE 'Vaildity reset' TO name6.
*UPDATING TEXTS
  MOVE 'Please select Client and User' TO com1000.
  MOVE 'This helps in assigning new passwords to the user' TO com104.
  MOVE 'Irrespective of its use earlier (no last 5 password history)' TO com104a.
  MOVE 'This copies the password of same user to a different client provided the user' TO com105.
  MOVE 'exists in destination client. Helpful for unlocking unknown/changed passwords' TO com105a.
  MOVE 'Removes the login error - User account not in validity date' TO com106.
  MOVE 'by resetting start and end validity date to 0s' TO com106a.
*NAMING THE BLOCKS
  MOVE 'User Information' TO block1.
  MOVE 'Unlock Users' TO block2.
  MOVE 'Change Developer Key' TO block3.
  MOVE 'Clear password change history' TO block4.
  MOVE 'Replicate password' TO block5.
  MOVE 'Reset user validity date' TO block6.
*BUTTON TEXTS
  MOVE 'Unlock User' TO btn_pass.
  MOVE 'Clear Password History' TO btn_chis.
  MOVE 'Remove Dev Key' TO btn_keyr.
  MOVE 'Add Dev Key' TO btn_keya.
  MOVE 'Copy Hash' TO btn_cpyh.
  MOVE 'Reset validity date' TO btn_vald.
************************************************************************
*         A-T  S-E-L-E-C-T-I-O-N  S-C-R-E-E-N  O-U-T-P-U-T             *
************************************************************************
AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF screen-name = 'P_BCODE'.
      screen-input = 0.
      MODIFY SCREEN.
    ENDIF.
    IF screen-name = 'P_UFLAG'.
      screen-input = 0.
      MODIFY SCREEN.
    ENDIF.
    IF screen-name = 'P_DEVKEY'.
      screen-input = 0.
      MODIFY SCREEN.
    ENDIF.
    IF screen-name = 'P_SLICNO'.
      screen-input = 0.
      MODIFY SCREEN.
    ENDIF.
    IF screen-name = 'P_USTYP'.
      screen-input = 0.
      MODIFY SCREEN.
    ENDIF.
    IF screen-name = 'P_CLASS'.
      screen-input = 0.
      MODIFY SCREEN.
    ENDIF.
    IF screen-name = 'P_GLTGV'.
      screen-input = 0.
      MODIFY SCREEN.
    ENDIF.
    IF screen-name = 'P_GLTGB'.
      screen-input = 0.
      MODIFY SCREEN.
    ENDIF.
    IF wa_usr02 IS INITIAL.
      IF screen-name = 'BTN_PASS'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
      IF screen-name = 'BTN_KEYR'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
      IF screen-name = 'BTN_KEYA'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
      IF screen-name = 'BTN_CHIS'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
      IF screen-name = 'P_DESTS'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
      IF screen-name = 'BTN_CPYH'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
      IF screen-name = 'BTN_VALD'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDIF.
  ENDLOOP.
************************************************************************
*                 A-T  S-E-L-E-C-T-I-O-N  S-C-R-E-E-N                  *
************************************************************************
******************** DROP DOWN LIST IS CHANGED *************************
AT SELECTION-SCREEN.
  CASE sy-dynnr.
    WHEN 1000.
      CASE sy-ucomm.
          WHEN'UCOM'.
          MESSAGE 'Updating client and user list' TYPE 'S'.
          PERFORM update_client_list.
          PERFORM update_user_list.
        WHEN 'ONLI'.
          PERFORM show_user_information.
        WHEN 'UNLOCK'.
          PERFORM unlock_user USING p_mandt p_bname.
          PERFORM show_user_information.
        WHEN 'REMKEY'.
          PERFORM remove_devaccess USING p_bname.
          PERFORM show_user_information.
        WHEN 'ADDKEY'.
          PERFORM add_unverified_devaccess USING p_bname.
          PERFORM show_user_information.
        WHEN 'CLR_HIST'.
          PERFORM clear_password_history USING p_mandt p_bname.
          PERFORM show_user_information.
        WHEN 'CPY_HASH'.
          PERFORM copy_hash USING p_mandt p_bname p_bcode p_dests.
          PERFORM show_user_information.
        WHEN 'RESDAT'.
          PERFORM reset_validity_date USING p_mandt p_bname.
          PERFORM show_user_information.
      ENDCASE.
  ENDCASE.
************************ F4 HELP FOR BNAME ******************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_bname.
*CLEAR ALL EXISTING DATA
*TO BE DONE EVERYTIME F4 HELP IS REQUESTED
  REFRESH it_usr02.
  REFRESH field_tab.
  field_tab-fieldname = 'BNAME'.
  field_tab-tabname = 'USR02'.
  APPEND field_tab.
*"----------------------------------------------------------------------
*"*"CALLING FUNCTION MODULE F4IF_INT_TABLE_VALUE_REQUEST
*"  EXPORTING
*"     retfield
*"  TABLES
*"     value_tab
*"     field_tab
*"     return_tab
*"----------------------------------------------------------------------
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
*   DDIC_STRUCTURE         = ' '
      retfield               = 'BNAME'
*   PVALKEY                = ' '
*   dynpprog               = ' '
*   DYNPNR                 = ' '
*   DYNPROFIELD            = ' '
*   STEPL                  = 0
*   WINDOW_TITLE           =
*   VALUE                  = ' '
*   VALUE_ORG              = 'C'
*   MULTIPLE_CHOICE        = ' '
*   DISPLAY                = ' '
*   CALLBACK_PROGRAM       = ' '
*   CALLBACK_FORM          = ' '
*   MARK_TAB               =
* IMPORTING
*   USER_RESET             =
    TABLES
      value_tab              = it_users
     field_tab              = field_tab
     return_tab             = return_tab
*   DYNPFLD_MAPPING        =
   EXCEPTIONS
     parameter_error        = 1
     no_values_found        = 2
     OTHERS                 = 3
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    p_bname = return_tab-fieldval.
  ENDIF.
************************ PRESS ENTER BNAME *****************************
AT SELECTION-SCREEN ON p_bname.
  PERFORM show_user_information.

************************************************************************
*                 S-T-A-R-T  O-F  S-E-L-E-C-T-I-O-N                    *
************************************************************************
START-OF-SELECTION.
************************************************************************
*                   E-N-D  O-F  S-E-L-E-C-T-I-O-N                      *
************************************************************************
END-OF-SELECTION.
************************************************************************
*                        T-O-P O-F P-A-G-E                             *
************************************************************************
************************************************************************
*                        E-N-D O-F P-A-G-E                             *
************************************************************************
************************************************************************
*                F-O-R-M-S / S-U-B R-O-U-T-I-N-E-S                     *
************************************************************************
*&---------------------------------------------------------------------*
*&      Form  update_client_list
*&---------------------------------------------------------------------*
*       fetches client numbers of available clients
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM update_client_list .
*REFRESHING THE LIST
  REFRESH list.
  SELECT mandt
           FROM t000
           INTO c_mandt.
    wa_list-key = c_mandt.
    wa_list-text = c_mandt.
    APPEND wa_list TO list.
  ENDSELECT.
*"----------------------------------------------------------------------
*"*"CALLING FUNCTION MODULE VRM_SET_VALUES
*"  EXPORTING
*"     id
*"     values
*"----------------------------------------------------------------------
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = 'P_MANDT'
      values          = list
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.                    " update_client_list
*&---------------------------------------------------------------------*
*&      Form  update_user_list
*&---------------------------------------------------------------------*
*       Updates the user selection help for client number selected
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM update_user_list .
  SELECT bname
         FROM usr02 CLIENT SPECIFIED
         INTO TABLE it_users
         WHERE mandt = p_mandt.
ENDFORM.                    " update_user_list
*&---------------------------------------------------------------------*
*&      Form  show_user_information
*&---------------------------------------------------------------------*
*       Updates on screen data
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM show_user_information .
  CLEAR wa_usr02.
  SELECT SINGLE *
         FROM usr02 CLIENT SPECIFIED
         INTO wa_usr02
         WHERE bname = p_bname
         AND mandt = p_mandt.
  IF sy-subrc NE 0.
    MESSAGE 'No Data for given user' TYPE 'S'.
  ENDIF.
  MOVE wa_usr02-bcode TO p_bcode.
  MOVE wa_usr02-uflag TO p_uflag.
  MOVE wa_usr02-ustyp TO p_ustyp.
  MOVE wa_usr02-class TO p_class.
  MOVE '' TO p_devkey.
  SELECT SINGLE accesskey
         FROM devaccess
         INTO p_devkey
         WHERE uname = p_bname.
*"----------------------------------------------------------------------
*"*"CALLING FUNCTION MODULE SLIC_GET_LICENCE_NUMBER
*"  IMPORTING
*"     license_number
*"----------------------------------------------------------------------
  CALL FUNCTION 'SLIC_GET_LICENCE_NUMBER'
    IMPORTING
      license_number = p_slicno.
*REFRESHING THE DESTINATION LIST
*SEE TAB 5 FOR THE DETAILS
  REFRESH dest.
  SELECT DISTINCT mandt
           FROM usr02 CLIENT SPECIFIED
           INTO c_dests
           WHERE bname = p_bname.
    wa_dest-key = c_dests.
    wa_dest-text = c_dests.
    APPEND wa_dest TO dest.
  ENDSELECT.
*"----------------------------------------------------------------------
*"*"CALLING FUNCTION MODULE VRM_SET_VALUES
*"  EXPORTING
*"     id
*"     values
*"----------------------------------------------------------------------
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = 'P_DESTS'
      values          = dest
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*UPDATE THE DATES - SEE TAB 6
  MOVE wa_usr02-GLTGV TO p_GLTGV.
  MOVE wa_usr02-GLTGB TO p_GLTGB.
ENDFORM.                    " show_user_information
*&---------------------------------------------------------------------*
*&      Form  unlock_user
*&---------------------------------------------------------------------*
*       Unlocks users who are locked
*----------------------------------------------------------------------*
*      -->P_P_MANDT  Client Number
*      -->P_P_BNAME  Username
*----------------------------------------------------------------------*
FORM unlock_user  USING    p_p_mandt
                           p_p_bname.
  DATA: cnt TYPE i.
  UPDATE usr02 CLIENT SPECIFIED
         SET uflag = '0'
         WHERE mandt = p_p_mandt
         AND bname = p_p_bname.
  SELECT COUNT(*) FROM usr02 CLIENT SPECIFIED WHERE mandt = p_p_mandt AND bname = p_p_bname AND uflag = '0'.
  IF sy-subrc EQ 0.
    MESSAGE 'User unlocked' TYPE 'S'.
  ELSE.
    MESSAGE 'Unlock failed' TYPE 'S'.
  ENDIF.
ENDFORM.                    " unlock_user
*&---------------------------------------------------------------------*
*&      Form  remove_devaccess
*&---------------------------------------------------------------------*
*       Removes developer keys
*----------------------------------------------------------------------*
*      -->P_P_BNAME  Username
*----------------------------------------------------------------------*
FORM remove_devaccess  USING    p_p_bname.
  DELETE FROM devaccess
         WHERE uname = p_p_bname.
  IF sy-subrc EQ 0.
    MESSAGE 'Developer Key removed' TYPE 'S'.
  ELSE.
    MESSAGE 'Removal failed / Key not found' TYPE 'S'.
  ENDIF.
ENDFORM.                    " remove_devaccess
*&---------------------------------------------------------------------*
*&      Form  clear_password_history
*&---------------------------------------------------------------------*
*       Clears previously used passwords making them reuseable
*----------------------------------------------------------------------*
*      -->P_P_MANDT  Client Number
*      -->P_P_BNAME  username
*----------------------------------------------------------------------*
FORM clear_password_history  USING    p_p_mandt
                                      p_p_bname.
  SELECT SINGLE * FROM usr02 CLIENT SPECIFIED
           INTO wa_usr02
           WHERE mandt = p_p_mandt
           AND bname = p_p_bname.
  IF sy-subrc = 0.
    wa_usr02-ocod1 = wa_usr02-ocod2 = wa_usr02-ocod3 = wa_usr02-ocod4 = wa_usr02-ocod5 = ''.
    wa_usr02-bcda1 = wa_usr02-bcda2 = wa_usr02-bcda3 = wa_usr02-bcda4 = wa_usr02-bcda5 = ''.
    MODIFY usr02 client specified FROM wa_usr02.
    IF sy-subrc EQ 0.
      MESSAGE 'Password history removed.' TYPE 'S'.
    ENDIF.
  ELSE.
    MESSAGE 'User not found' TYPE 'S'.
  ENDIF.
*Password change history is stored in USH02.
* do not enable this.. you wont be able to login.
*  delete from ush02 client specified
*             WHERE mandt = p_p_mandt
*             AND bname = p_p_bname.
ENDFORM.                    " clear_password_history
*&---------------------------------------------------------------------*
*&      Form  add_unverified_devaccess
*&---------------------------------------------------------------------*
*       Add developer key(will not help if incorrect)
*----------------------------------------------------------------------*
*      -->P_P_BNAME  Username
*----------------------------------------------------------------------*
FORM add_unverified_devaccess  USING    p_p_bname.
  DATA: fields TYPE TABLE OF sval WITH HEADER LINE,
        retcode TYPE c.
  DATA: wa_devaccess TYPE devaccess.
  fields-tabname = 'DEVACCESS'.
  fields-fieldname = 'ACCESSKEY'.
  APPEND fields.
*"----------------------------------------------------------------------
*"*"CALLING FUNCTION MODULE POPUP_GET_VALUES
*"  EXPORTING
*"     popup_title
*"  IMPORTING
*"     returncode
*"  TABLES
*"     fields
*"----------------------------------------------------------------------
  CALL FUNCTION 'POPUP_GET_VALUES'
    EXPORTING
*   NO_VALUE_CHECK        = ' '
      popup_title           = 'Enter Working Developer Key Only'
*   START_COLUMN          = '5'
*   START_ROW             = '5'
   IMPORTING
     returncode            = retcode
    TABLES
      fields                = fields
   EXCEPTIONS
     error_in_fields       = 1
     OTHERS                = 2
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  IF retcode = 'A'.
    MESSAGE 'Change in Developer Key cancelled' TYPE 'S'.
    EXIT.
  ELSE.
    wa_devaccess-uname = p_p_bname.
    LOOP AT fields.
      IF fields-fieldname = 'ACCESSKEY'.
        wa_devaccess-accesskey = fields-value.
      ENDIF.
    ENDLOOP.
    IF STRLEN( wa_devaccess-accesskey ) EQ 20.
      MODIFY devaccess FROM wa_devaccess.
      IF sy-subrc EQ 0.
        MESSAGE 'Unverified key added to devaccess' TYPE 'S'.
      ELSE.
        MESSAGE 'Cannot add the key' TYPE 'S'.
      ENDIF.
    ELSE.
      MESSAGE 'Key length is too short' TYPE 'S'.
    ENDIF.
  ENDIF.
ENDFORM.                    " add_unverified_devaccess
*&---------------------------------------------------------------------*
*&      Form  copy_hash
*&---------------------------------------------------------------------*
*       Copy user password to another client for same user
*----------------------------------------------------------------------*
*      -->P_P_MANDT  Current Client Number
*      -->P_P_BNAME  Username
*      -->P_P_BCODE  Password Hash
*      -->P_P_DESTS  Destination Client Number
*----------------------------------------------------------------------*
FORM copy_hash  USING    p_p_mandt
                         p_p_bname
                         p_p_bcode
                         p_p_dests.
  IF p_p_mandt NE p_p_dests.
    SELECT SINGLE *
           FROM usr02 CLIENT SPECIFIED
           INTO wa_usr02
           WHERE mandt = p_p_dests
           AND bname = p_p_bname.
    IF sy-subrc EQ 0.
      wa_usr02-bcode = p_p_bcode.
      MODIFY usr02 client specified FROM wa_usr02.
      IF sy-subrc EQ 0.
        MESSAGE 'Successfully copied' TYPE 'S'.
      ELSE.
        MESSAGE 'Copy failed' TYPE 'S'.
      ENDIF.
    ENDIF.
  ELSE.
    MESSAGE 'Source and destination client is same' TYPE 'S'.
  ENDIF.
ENDFORM.                    " copy_hash
*&---------------------------------------------------------------------*
*&      Form  reset_validity_date
*&---------------------------------------------------------------------*
*       Resets the user validity date
*----------------------------------------------------------------------*
*      -->P_P_MANDT  Client Number
*      -->P_P_BNAME  Username
*----------------------------------------------------------------------*
form reset_validity_date  using    p_p_mandt
                                   p_p_bname.
select single *
         from usr02 client specified
         into wa_usr02
         where mandt = p_p_mandt
         and bname = p_p_bname.
    IF sy-subrc EQ 0.
      wa_usr02-GLTGV = '00000000'.
      wa_usr02-GLTGB = '00000000'.
      MODIFY usr02 client specified FROM wa_usr02.
      IF sy-subrc EQ 0.
        MESSAGE 'validity dates were reset' TYPE 'S'.
      ELSE.
        MESSAGE 'Reset failed' TYPE 'S'.
      ENDIF.
    ENDIF.
endform.                    " reset_validity_date

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