Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Remove specific Profiles per user

yoppy_santoso
Participant
0 Kudos

Hi all,

Is there FM/BAPI for deleting specific Profiles in user ?
if it's not there, how to delete it using abap?

Thank's

1 ACCEPTED SOLUTION

VeselinaPeykova
Active Contributor

I am not a developer, but maybe I would try this first (assuming that you meant local profiles):
1. Get the list of the currently assigned profiles to the user with BAPI_USER_GET_DETAIL.
2. Delete all assigned profiles with BAPI_USER_PROFILES_DELETE.
3. Assign the profiles which you need to keep with BAPI_USER_PROFILES_ASSIGN.

Frankly speaking, I would use SU10 unless there is a very good reason for custom development.

4 REPLIES 4

VeselinaPeykova
Active Contributor

I am not a developer, but maybe I would try this first (assuming that you meant local profiles):
1. Get the list of the currently assigned profiles to the user with BAPI_USER_GET_DETAIL.
2. Delete all assigned profiles with BAPI_USER_PROFILES_DELETE.
3. Assign the profiles which you need to keep with BAPI_USER_PROFILES_ASSIGN.

Frankly speaking, I would use SU10 unless there is a very good reason for custom development.

0 Kudos

Okay Veselina

Initially I also thought that way, I thought there was an FM that covered all processes.
But, many thanks for your time

0 Kudos

Hi Veselina,

Ur scenario succes with Composite Profile, but not working with Generate Profile.
I have profile like this :

SAP_ALL is Composite Profile

Why cannot Generate Profile?

For generated profiles I think that a better approach is to add or remove these through role assignment.

While it is possible to delete generated profiles via BAPI_USER_PROFILES_DELETE it does not seem the right thing to do, because the role will still be present in the user data, but without any profile.

For generated profiles I would use BAPI_USER_ACTGROUPS_DELETE and

BAPI_USER_ACTGROUPS_ASSIGN.

So, if you have a combination of profiles linked to roles and you have SAP_ALL for an user:

1. Use BAPI_USER_GET_DETAIL to find this out (you have the roles in ACTIVITYGROUPS and the generated profiles are in PROFILES with BAPITYPE = 'G'. You also get the role validity, which you might need at a later stage if you want to assign them again.

2. Delete the role assignments with BAPI_USER_ACTGROUPS_DELETE.

3. Delete SAP_ALL with BAPI_USER_PROFILES_DELETE.

4. Add the roles which you need with BAPI_USER_ACTGROUPS_ASSIGN.

5. Add the composite profiles (if needed).