When you have to deactivate the pasword of a large list of userts, you could use this script. For a smaller set of users you can also use Trx SU10.

First of all you need a list of all users…

Then you can copy paste all values of BNAME into this report.

  1. REPORT  Z_USERS_DEACTIVATE.
  2.  
  3. TABLES: USR02.
  4. DATA: lv_username TYPE BAPIBNAME-BAPIBNAME,
  5. wa_logondata TYPE BAPILOGOND,
  6. wa_logondatax TYPE BAPILOGONX,
  7. lt_return TYPE BAPIRET2_T,
  8. lt_usr02 TYPE TABLE OF USR02,
  9. wa_usr02 TYPE USR02.
  10.  
  11. SELECT-OPTIONS: p_usids FOR USR02-BNAME.
  12.  
  13.  
  14. SELECT * FROM USR02 INTO TABLE lt_usr02 WHERE BNAME IN p_usids.
  15.  
  16. LOOP AT  lt_usr02 INTO  wa_usr02.
  17.  
  18.   lv_username = wa_usr02-BNAME.
  19.   wa_logondata-codvn  = 'X'.
  20.   wa_logondatax-codvn = 'X'.
  21.   CALL FUNCTION 'BAPI_USER_CHANGE'
  22.     EXPORTING
  23.       username   = lv_username
  24.       logondata  = wa_logondata
  25.       logondatax = wa_logondatax
  26.     TABLES
  27.       return     = lt_return.
  28.  
  29.   DELETE lt_return WHERE TYPE <> 'E'.
  30.   IF lt_return IS INITIAL.
  31.     WRITE: / 'Deactivated password:' , lv_username .
  32.  ELSE.
  33.     WRITE: / 'ERROR:' , lv_username  .
  34.   ENDIF.
  35. ENDLOOP.


Leave a Comment