*&---------------------------------------------------------------------*
*& Report ZZCHANGE_PW
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report zzchange_pw.
data: new_user type xubname,
password type rfcauth,
message(120),
wa_user_data type zsystem_master_c,
return like bapiret2 occurs 0 with header line,
profiles like bapiprof occurs 0 with header line,
activitygroups like bapiagr occurs 0 with header line.
activitygroups-agr_name = 'LCT_CONVERSION'.
append activitygroups.
profiles-bapiprof = 'T-LT780009'.
append profiles.
select single * from zsystem_master_c into
wa_user_data where rfcdest = '<A1S_TO_A1S>'.
call function 'ZENCODE_RFC_DATA'
EXPORTING
user = wa_user_data-rfcuser
code = wa_user_data-rfcpw
option = 'D'
IMPORTING
value_r = password.
if sy-mandt = '000'.
new_user = 'RFC_CONV'.
perform change_role using new_user.
perform change_password using new_user password.
elseif sy-mandt = '001'.
do 2 times.
if sy-index = 1.
* Create LCT User LCT_USER for conversion purposes in client 001
new_user = 'LCT_USER'.
perform change_role using new_user.
elseif sy-index = 2.
activitygroups-agr_name = 'SAP_J2EE_ADMIN'.
append activitygroups.
new_user = 'IDESADM'.
perform change_role using new_user.
endif.
perform change_password using new_user password.
enddo.
endif.
*&---------------------------------------------------------------------*
*& Form get_additional_user_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_additional_user_data .
select single * from zsystem_master_c into
wa_user_data where rfcdest = 'A1S_TO_A1S'.
call function 'ZENCODE_RFC_DATA'
EXPORTING
user = wa_user_data-rfcuser
code = wa_user_data-rfcpw
option = 'D'
IMPORTING
value_r = password.
endform. "get_additional_user_data
*&---------------------------------------------------------------------*
*& Form change_password
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->NEW_USER text
* -->PASSWORD text
*----------------------------------------------------------------------*
form change_password using new_user password.
call function 'BAPI_USER_CHANGE'
EXPORTING
username = new_user
password = password
passwordx = 'X'
TABLES
return = return.
append return.
* User entsperren (durch Falschanmeldungen wahrscheinlich gesperrt)
call function 'BAPI_USER_UNLOCK'
EXPORTING
username = new_user
TABLES
return = return.
endform. " change_password
*&---------------------------------------------------------------------*
*& Form change_role
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NEW_USER text
*----------------------------------------------------------------------*
FORM change_role USING NEW_USER.
* Assign activity groups to users
* clear return.
call function 'BAPI_USER_ACTGROUPS_ASSIGN'
EXPORTING
username = new_user
TABLES
activitygroups = activitygroups
return = return.
* Assign profiles to user
clear return.
call function 'BAPI_USER_PROFILES_ASSIGN'
EXPORTING
username = new_user
TABLES
profiles = profiles
return = return.
ENDFORM. " change_role