1-) Getting blocked user list
2-) Unblock user accounts.
Selection Screen:

Codes:
report zanil.
* This Program Unblocks Users SAP Accounts
* Block values:
* 1. 32 – Locked Globally By Administrator
* 2. 64 – Locked Locally By Administrator
* 3. 128 – Locked Due To Incorrect Logons (Limited Term)
tables: usr02.
select–options: s_bname for usr02–bname.
parameters: p_32 as checkbox.
parameters: p_64 as checkbox.
parameters: p_128 as checkbox.
start–of–selection.
data lt_return type table of bapiret2.
data lt_usr02 type table of usr02.
data ls_usr02 type usr02.
data ls_return type bapiret2.
data lv_message type string.
* Getting all blocked user list
select * from usr02
into corresponding fields of table lt_usr02
where bname in s_bname
and uflag ne ‘0’.
* Deleting globally data if not checked.
if p_32 is initial.
delete lt_usr02 where uflag eq ’32’.
endif.
* Deleting locally data if not checked.
if p_64 is initial.
delete lt_usr02 where uflag eq ’64’.
endif.
* Deleting incorrect data if not checked.
if p_128 is initial.
delete lt_usr02 where uflag eq ‘128’.
endif.
if lt_usr02[] is initial.
message ‘No data found!’ type ‘W’.
exit.
endif.
loop at lt_usr02 into ls_usr02.
clear: lt_return, ls_return, lv_message.
call function ‘BAPI_USER_UNLOCK’
exporting
username = ls_usr02–bname
tables
return = lt_return.
read table lt_return into ls_return
with key type = ‘S’.
if sy–subrc eq 0.
concatenate ls_usr02–bname
‘unblocked succesfully’
into lv_message.
else.
concatenate ls_usr02–bname
‘failed’
into lv_message.
endif.
write :/ lv_message.
endloop.




