03-07-2007 3:09 PM
I've written a user conversion program that utilizes BAPI_USER_ACTGROUPS_ASSIGN to assign roles to users. This bapi does not work. The first userid in the file gets assigned his/her role. However subsequent user roles are not saved to the database even though the bapi return a successful message. To test this:
1. Create 3 users via SU01. Call then AAA, BBB, CCC. Do not assign roles.
2. Create and execute the code below.
3. In my system the bapi only saves roles for AAA.
report ZROLES.
data: v_userid like bapibname-bapibname.
data: actgroups type bapiagr occurs 0 with header line.
data: return like bapiret2 occurs 0 with header line.
start-of-selection.
do.
case sy-index.
when 1.
v_userid = 'AAA'.
when 2.
v_userid = 'BBB'.
when 3.
v_userid = 'CCC'.
when others.
exit.
endcase.
refresh: actgroups,
return.
clear return.
actgroups-agr_name = 'SAP_ISA_B2B_ORDER'.
actgroups-from_dat = '20070201'.
actgroups-to_dat = '20070401'.
append actgroups.
actgroups-agr_name = 'SAP_ISA_B2B_VIEW'.
actgroups-from_dat = '20070201'.
actgroups-to_dat = '20070401'.
append actgroups.
call function 'BAPI_USER_ACTGROUPS_ASSIGN'
exporting
username = v_userid
tables
activitygroups = actgroups
return = return.
write:/ v_userid.
loop at return.
write:/ return-type, return-message.
endloop.
skip.
enddo.
03-07-2007 3:11 PM
Hello,
Check this:
FU BAPI_USER_ACTGROUPS_ASSIGN
____________________________________________________
Short text
User: Change entire activity group assignment
Functionality
The user activity group assignments are transferred in an ACTIVITYGROUPS
table. All existing assignments are overwritten by the assignments in
this table. This also means that existing assignments can be deleted if
they are no longer contained in the table.
Only the fields
ACTIVITYGROUPS-AGR_NAME
ACTIVITYGROUPS-FROM_DAT
ACTIVITYGROUPS-TO_DAT
must be filled.
If the date of the link is not specified,
ACTIVITYGROUPS-FROM_DAT is set to the current date and
ACTIVITYGROUPS-FROM_DAT is set to 31.12.9999.
Example
User SAMPLE has been assigned the following activity groups:
AGR1 01.01.98 01.01.99
AGR2 01.01.98 01.01.99
AGR3 01.01.98 01.01.99
You want to delete
AGR1 01.01.98 01.01.99 and insert
AGR4 02.01.98 01.03.99.
Transfer table ACTIVITYGROUPS with the following contents:
AGR2 01.01.98 01.01.99
AGR3 01.01.98 01.01.99
AGR4 02.01.98 01.03.99
If useful reward.
Regards,
Vasanth
03-07-2007 3:20 PM
Vasanth
I realize that the entire role profile gets overriden. However, these are brand new users not existing ones. The code snippet that I attached is only a sample. The actual conversion program reads the existing roles and appends any new ones.
Lenny
03-07-2007 3:16 PM
Oops. I forgot some impotant info.
1. This is being run in ECC5.
2. SAP_BASIS support pack SAPKB64015.
3. It seems to only occur when applying composite roles.
06-30-2015 1:44 AM
I had the same problem.
Turned out to be a poor work area cleaning.
Always use
actgroups-agr_name = 'SAP_ISA_B2B_VIEW'.
actgroups-from_dat = '20070201'.
actgroups-to_dat = '20070401'.
clear actgroups-ORG_FLAG.
append actgroups.
Solved my problem.