Sub topic 3
PFCG roles and how profiles are generated
This chapter assumes you know what an authorization object, field and activity are (covered in the previous chapter). It also assumes you can log on to a development system and open transaction PFCG. By the end, you should be able to follow a role from its menu to the profile that the kernel checks at runtime.
What a PFCG role is
A PFCG role is a container maintained in transaction PFCG (Role Maintenance). It holds three kinds of information:
- A menu of the transactions, apps and services the role gives access to.
- Authorization data, which is the set of authorization objects with field values.
- A list of users who receive the role.
The role itself is never checked when a user runs an app. The AUTHORITY-CHECK statement and the launchpad services read an authorization profile, which the system generates from the role's authorization data. The role is the source and the profile is the compiled result.
In Fiori-based systems, the business roles you meet later in this tutorial sit on top of this mechanism. A business role combines catalogs, which control what the user can open, with a PFCG role, which controls what the user can do inside those apps. This chapter covers the PFCG half.
The tabs of a role
| Tab | Purpose | Main tables |
|---|---|---|
| Description | Name, text, and a long description of the role | AGR_DEFINE, AGR_TEXTS |
| Menu | Transactions, reports, apps and services included | AGR_TCODES, AGR_HIER |
| Authorizations | Authorization objects, fields, values and generation status | AGR_1250, AGR_1251 |
| User | Users assigned, with validity dates and comparison | AGR_USERS |
| Personalization | Preferences such as favorites and links | AGR_BUFFI |
The tabs follow the order of work. You add menu entries, then maintain authorizations, then generate the profile, then assign users.
The generation chain
The chain starts at the menu. When you add a transaction or app to the Menu tab, PFCG looks up the SU24 defaults for that object. SU24 stores, per application, which authorization objects it checks and which values are proposed. PFCG copies these proposals into the role's authorization data. The next chapters cover SU24 in detail.
The steps work as follows:
- Menu. You add transactions, apps or services. The system adds the objects that these entries check, such as
S_TCODE, and the objects proposed in SU24. - Authorization data. You fill the empty fields. Organizational levels such as company code or sales organization are shown in a separate "Org. levels" block so that you set them once for the whole role.
- Generation. The Generate button creates authorizations from the data and a profile that contains them.
- User comparison. When users are assigned, the profile is entered into their user master records.
Statuses of authorization data
Each node in the authorization tree has a traffic-light status and a maintenance status. These statuses show how the data came to be.
| Status | Meaning |
|---|---|
| Standard | Values come unchanged from the SU24 proposal. |
| Maintained | You filled in all required fields. |
| Changed | You changed the proposed values. |
| Manually | You added the object yourself, not from SU24. |
| Open | Required fields are still empty. |
A role cannot be generated while any object has the status Open. Open fields usually are organizational values you have not yet set. Entering * in an organizational field gives access to all values, so use it with care.
If you later change the menu, PFCG runs a comparison against the current SU24 data. It marks objects as new, changed or no longer proposed. This is why you should never edit objects that SU24 has already supplied without knowing it will come up again at the next comparison.
Profiles and what the generator creates
When you generate, the system creates:
- Authorizations. Each authorization is a named combination of values for one object, for example
F_BKPF_BUKwithBUKRS = 1000andACTVT = 03. - An authorization profile. The profile is a named list of authorizations. Its name starts with
T-followed by generated characters, for exampleT-SD12345, unless you set a profile name yourself on the Authorizations tab. - A link between role and profile, stored in table
AGR_1016.
One profile can hold only a limited number of authorizations (312 in current releases). If a role needs more, the generator creates additional profiles for the same role. A role that is this large is usually too broad and should be split.
When a user logs on, the system loads all of the user's profiles into the user buffer. The AUTHORITY-CHECK statement then searches that buffer. The buffer is also size-limited, which is a second reason to keep roles small.
Single, composite and derived roles
- A single role holds its own menu and authorization data.
- A composite role holds no authorization data. It is a bundle of single roles, so assigning one composite role assigns all of its members. The composite role gets a profile that lists the profiles of its members.
- A derived role inherits menu and authorization structure from a parent role. You only maintain the organizational values in the derived role. This lets you keep one parent for "Accounts Payable Clerk" and derive one child per company code group.
Composite roles do not reduce the authorizations a user ends up with. They only make assignment easier, and profiles are always combined by union. If one profile grants access, a second profile cannot remove it.
User comparison
Generating a role does not change user records by itself. The user comparison, started on the User tab or by report PFCG_TIME_DEPENDENCY, copies profiles into the user master record. Roles have validity dates, so the comparison also removes profiles when an assignment expires. If you assign roles and users do not get access, check whether the comparison has run. The profile entries are stored in table UST04, and the role assignments in AGR_USERS.
Reading role data in ABAP
The following report lists the profiles generated for a role and the active authorization values stored in its authorization data. It runs in any ABAP system that has the standard role tables.
REPORT zlist_role_profile.
PARAMETERS p_role TYPE agr_name OBLIGATORY.
START-OF-SELECTION.
SELECT agr_name, profile
FROM agr_1016
WHERE agr_name = @p_role
INTO TABLE @DATA(lt_profiles).
IF lt_profiles IS INITIAL.
WRITE: / 'No generated profile found for role', p_role.
RETURN.
ENDIF.
LOOP AT lt_profiles INTO DATA(ls_profile).
WRITE: / 'Profile:', ls_profile-profile.
ENDLOOP.
SELECT object, field, low, high
FROM agr_1251
WHERE agr_name = @p_role
AND deleted = @space
ORDER BY object, field
INTO TABLE @DATA(lt_values).
LOOP AT lt_values INTO DATA(ls_value).
WRITE: / ls_value-object, ls_value-field, ls_value-low, ls_value-high.
ENDLOOP.Table AGR_1251 holds the maintained data of the role. The generated profile contains the same values, but in the form the runtime reads.
Common errors
- Profile not generated. The authorization tab shows a red or yellow light. At least one object is still Open. Fill in the organizational values.
- Profile generated but users still have no access. The user comparison did not run, or the role assignment has expired. Check the User tab.
- Access is wider than planned. An object was added manually, or
*was entered in a field. Look for objects marked Manually and for objects with full values. - Changes appear in the development system only. Roles are transported. The profile is generated again in the target system through the transport, or through
PFCG_MASS_TRANSPORT-style tools. Authorization data and the profile must stay in sync, so always transport the role after you regenerate it. - Roles with hundreds of objects. This is a design problem, not a generation problem. Split the role by job function.
Summary
A PFCG role defines a menu, authorization data and users. Generating the role turns the data into authorizations and a profile. The comparison enters that profile into the user master record. The system checks only profiles, so any change to a role has an effect only after you regenerate it and the users are compared.
Exercise
A colleague adds a new app to the Menu tab of a role that is already assigned to 50 users. The role shows a yellow status on the Authorizations tab. What must happen before the users can open the new app and use it, and why?
Show answer
The new app brings SU24 proposals that are not yet maintained, so some objects or organizational fields are Open or changed. You must maintain those values, generate the profile again, and run the user comparison so that the updated profile is in the 50 user master records. Until the profile is regenerated, the runtime still reads the old profile, which does not contain the authorizations for the new app.
Exercise
A composite role contains two single roles. One grants display access to company code 1000, and the other grants change access to company code 1000. Can a user with the composite role change documents in company code 1000?
Show answer
Yes. Profiles are combined by union, and a check succeeds if any authorization in the user buffer satisfies it. The composite role does not remove or narrow what its member roles grant.