cancel
Showing results for 
Search instead for 
Did you mean: 

Create Modify or delete role objects using BApi

caristeo
Discoverer
0 Kudos
159

Hi,

I need to know if there is any way to modify create or add objects to roles. I am seeing that the only standard thing is to use the /GRCPI/GRIA_MASS_UPD_ROLE function , I also use other functions to achieve my purpose such as PRGN_AUTO_GENERATE_PROFILE_NEW and i use the RFC_READ_TABLE function to read from the AGR_DEFINE table and there if a role is a parent or child. At the end I commit the changes with the bapi. But I can't get it to change or add any object to the role.

Regards

Sandra_Rossi
Active Contributor
Fullstack_Dev
Explorer
0 Kudos

To add or change objects in roles within an SAP system, there are specific steps and functions you can use beyond those you’ve already mentioned. Here’s a possible approach:

Use Transaction PFCG: In transaction PFCG, you can manually modify roles and add or remove objects. If you want to automate this process, various BAPIs and function modules come into play.

Function Modules for Changing Authorizations: PRGN_1252_AUTH_ADD: This function module adds authorization objects to a role. PRGN_1252_AUTH_CHANGE: This allows you to modify the authorizations of a role. This is helpful for changing existing authorizations or adding new ones.

Use BAPIs to Update the Role:

BAPI_ROLE_SAVE: This BAPI is used to save a role after editing, similar to using transaction PFCG. BAPI_ROLE_ACTGROUP_ASSIGN: This allows you to assign authorizations to a role. Checking and Reading Authorization Objects:

Use function modules like RFC_READ_TABLE to read information about authorization objects from tables like AGR_1251 (role authorizations) and AGR_DEFINE (role definition), just as you are already doing.

Mass Changes with /GRCPI/GRIA_MASS_UPD_ROLE: The function /GRCPI/GRIA_MASS_UPD_ROLE, which you mentioned, is also useful for making mass changes to roles, but for specifically changing an authorization object in a role, BAPIs are often the better choice.

Commit the Changes: After you’ve added or modified the objects, you need to ensure that you properly the changes. You can do this by using BAPI_TRANSACTION_COMMIT after the role modification or saving.

If you cannot change a specific role or authorization object, the following might be relevant: Missing Authorizations: Check if you have the necessary permissions to modify roles. Object Anchored in Another Role: Sometimes, objects are set in higher-level or derived roles. This could explain why your changes aren’t taking effect.

If you have more details about a specific error or scenario, I can provide more targeted assistance.

 

** ADDED BY MODERATION** GenAI Assisted Content

Accepted Solutions (0)

Answers (1)

Answers (1)

caristeo
Discoverer
0 Kudos

I tried to find PRGN_1252_AUTH_ADD or something related functions PRGN_1252_AUTH_CHANGE and not exist. And BAPI_ROLE_ACTGROUP_ASSIGN is just for user assign role, and BAPI_ROLE_SAVE not exist, and i want to use Bapi remotely.. If there is any existing in sap or what bapi do I need to develop to get it.

Regards

Sandra_Rossi
Active Contributor
0 Kudos
I'm not surprised, it was GenAI Assisted Content.