Skip to Content
0

Use reference user to create new user, assign defaults and roles

Jan 25, 2017 at 07:49 AM

226

avatar image

Hey,

I Need to create a new user via the function module 'BAPI_USER_CREATE1'. I'm using the ref_user value to Hand over a reference user.

The Problem is that the values in section 'defaults' aren't assigned. Also the roles are not visible until a click on the button next to the reference user (like shown in the picture).

So how can I assign values like 'Defaults' and 'Roles' from a reference user to my new user. Do I have to do that manually with reading a table and using another function module?

Thanks for any hints!

unbenannt1.png (2.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Dominic Überall Jan 30, 2017 at 12:43 PM
1

Hey thanks for your help! :)

I managed it like this right now:

I'm getting the reference user's roles with function module 'BAPI_USER_GET_DETAIL' and save them in an internal table. Then I create a new user with 'BAPI_USER_CREATE1' and afterwards I assign the roles via the function module: 'BAPI_USER_ACTGROUPS_ASSIGN'.

That works for us right now pretty good. :)

Share
10 |10000 characters needed characters left characters exceeded
Dominic Überall Jan 25, 2017 at 08:22 AM
0

Ok the problem with the default values and so is solved. I just pass them through with the parameter structure 'defaults' in the function module. I missed that part at first.

But the problem with the roles remain. Are they assigned already if it looks like in the picture shown in my question above?

Show 2 Share
10 |10000 characters needed characters left characters exceeded

I think you have a slight misunderstanding about the reference user. You have created an inheritance instead of direct role assignments. If you change your reference users' rights it will immediately affect all user accounts that refer to this user.

I'd like to suggest you either assign roles in a separate action after creating the users or start creating the users as a complete copy of your 'reference user' to get the correct role assignments right away.

1

Ah ok. Thanks for the explanation, helps me very much :) Answers like that are always very helpful because they don't just solve the problem but help understandig the source of it and how to avoid it in the future. That's how young developers can step forward. So thank you very much for your help on this topic :) I will describe the solution I'm using right now in a comment below.

1
Raymond Giuseppi
Jan 27, 2017 at 08:21 AM
0

If you actually want to copy an user and not build an inheritance as Jurjen wrote, better read and copy data from 'reference user' to 'new user'.

BAPI_USER_GET_DETAIL 
> BAPI_USER_CREATE1, BAPI_USER_ACTGROUPS_ASSIGN, BAPI_USER_PROFILES_ASSIGN
BAPI_USER_WP_PERS_DATA_READ
> BAPI_USER_WP_PERS_DATA_SAVE
etc.

Regards,
Raymond

Share
10 |10000 characters needed characters left characters exceeded