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: 

Change Expiry date of the role assigned to user.

Former Member
0 Kudos

Hello Experts,

My requirement is through ABAP Code i want to extract the Role assigned to a User and chnage its Expiry date by system date.

Could anyone let me know the BAPI for this?

I have found one BAPI through which we can able to check the roles "BAPI_USER_GET_DETAIL", but found nothing through which we can change expiry date of the role assigned to the user.

Please suggest some solution for this.

Thanks.

1 ACCEPTED SOLUTION

Former Member

Hi ,

Check below Steps..

  • Pass User Name in to "BAPI_USER_GET_DETAIL."  and Fetch Role name and Role Valid from to Valid To .
  • Call this FM "SUSR_BAPI_USER_ACTGROUPS_ASSIG" and Pass User Name and Fetch Role Name from above BAPI with New Valid from to New Valid To date .

OR

Fetch All Respective Role Name from 'AGR_USERS" Table for Particular User and then Pass the Role Name with New dates as per your requirement to FM SUSR_BAPI_USER_ACTGROUPS_ASSIG .

Regard's

Smruti

9 REPLIES 9

egenoves
Participant
0 Kudos

Hi prachi,

i've no experience with roles through abap,

but i think this function may help you : SUSR_USER_SURFACE_MAINT_ATTRIB.

it has a table parameter typed with structure called USAGR that is the same that you have in the Roles Maintenance screen in SU01

Hope it helps,

Regards

Former Member
0 Kudos

Hi Enrique,

Thanks for the instant reply.

SUSR_USER_SURFACE_MAINT_ATTRIB has Role , From and To in structure USAGR, but this function module does not allow for change the Date of Role.

Can you suggest some other solution for this?

0 Kudos

i'm sorry... my answer was wrong.

Instead i've tested Smruti Ranjan Mohanty solution below and i've modify my user role ...

Smruti Ranjan Mohanty solution is correct

Good to know, thats new for me, thanks Smruti!

Regards

Former Member

Hi ,

Check below Steps..

  • Pass User Name in to "BAPI_USER_GET_DETAIL."  and Fetch Role name and Role Valid from to Valid To .
  • Call this FM "SUSR_BAPI_USER_ACTGROUPS_ASSIG" and Pass User Name and Fetch Role Name from above BAPI with New Valid from to New Valid To date .

OR

Fetch All Respective Role Name from 'AGR_USERS" Table for Particular User and then Pass the Role Name with New dates as per your requirement to FM SUSR_BAPI_USER_ACTGROUPS_ASSIG .

Regard's

Smruti

0 Kudos

Hi Smruti Ranjan Mohanty,

Thanks for soultion. It worked.

Former Member
0 Kudos

Prachi,

  • First fetch AGR_NAME from AGR_USERS table. And then pass the AGR_NAME, FROM_DAT & T_DAT to the ACTIVITYGROUPS in tables. And also pass User Name in USERNAME in import parameter.

         

This will work.

Regards

Vivek Goyal

0 Kudos

HI Vivek,

I have done the same, but the BAPI is not working. I have written following code for it:

 

LOOP AT it_agr_users INTO wa_agr_users WHERE uname = gs_usr02-bname.
username
= gs_usr02-bname.
activitygroups
-agr_name = wa_agr_users-agr_name.
activitygroups
-from_dat = wa_agr_users-from_dat.
activitygroups
-to_dat = sy-datum.
CALL FUNCTION 'BAPI_USER_ACTGROUPS_ASSIGN'
EXPORTING
username
= username
tables
activitygroups
= activitygroups
return = it3_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.

Here it_agr_users contains all the users whose role expiry date needs to be modified.

Please suggest.

0 Kudos

Check these Notes :

320460 - BAPI_USER_ACTGROUPS_ASSIGN: Perfo. problems

1240208 - BAPI_USER_ACTGROUPS_ASSIGN: Profile is not assigned

1505943 - BAPI_USER_ACTGROUPS_ASSIGN: Incorrect merging

Regard's

Smruti

0 Kudos

Prachi,

I tried with SUSR_BAPI_USER_ACTGROUPS_ASSIG this only. And it it working for me.

What is the error you are getting in return table?