Sub topic 10
Restricting roles by organizational values
This chapter assumes you know what an authorization object, field and activity are, that a business role bundles business catalogs, and that PFCG generates authorization data for a role. Here you will limit a role to specific company codes, plants or sales organizations.
Why restrict a role
A business role such as "Accounts Payable Accountant" is written once and assigned to many people. Two accountants in different countries need the same apps but must not see the same company codes. Instead of building one role per company code, you keep one role and set organizational values on it. These values fill the organizational fields of the authorization objects, for example BUKRS (company code), WERKS (plant) or VKORG (sales organization).
How restrictions work
Apps in the role's catalogs bring SU24 default values with them. Organizational fields usually arrive empty or open, and they appear in PFCG as open fields or as organizational levels. If you leave a field open, the role grants nothing for it, so the user fails the authority check. If you enter *, the role grants everything. Entering explicit values grants only those values.
Setting the values in PFCG
- Open the role in transaction PFCG and go to the Authorizations tab.
- Choose to change the authorization data. If the profile is new, the system shows the open organizational levels first.
- Enter values in the organizational level fields, such as company code
1010or a range1010to1030. - Generate the profile.
Organizational levels are fields that occur in many authorization objects. Entering a value once fills every object that uses the field. You can still overwrite a single object later, but then it no longer follows the level.
| Value you enter | Effect |
|---|---|
| `1010` | Only company code 1010 |
| `1010` to `1030` | Company codes in that range |
| `*` | All company codes |
| Empty | No access to that field |
Two ways to scale
Both approaches use one parent role and derived copies.
- Derived roles: A derived role inherits the menu and authorization objects from a parent role. You maintain only the organizational values in each derived role. A change to the parent applies to all children after you adjust and regenerate.
- Separate custom roles per region: Easier to read, but each copy must be maintained on its own and drifts over time.
Derived roles keep the work small when you have many organizational units, for example one derived role per country.
Restrictions in code
The same values are what the system compares in ABAP and CDS. The check below fails for a user whose role does not include the requested company code.
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'BUKRS' FIELD lv_company_code
ID 'ACTVT' FIELD '03'.
IF sy-subrc <> 0.
MESSAGE e000(00) WITH 'No authorization for company code' lv_company_code.
ENDIF.Common errors
- A new user sees no data although the app opens. The organizational field is still open in the role. Enter the values and regenerate the profile.
- A change in PFCG has no effect. The profile was not regenerated, or the user's authorizations were not compared after the role changed.
- One object ignores your organizational level. Someone overwrote it manually. Reset it to the level value.
- A derived role shows old data. The parent changed but the derived role was not regenerated.
Exercise
An accountant opens an app from her business role but sees no journal entries. SU53 shows a failed check on FBKPFBUK for field BUKRS, and the role's company code level is empty. What do you change, and why not enter *?
Show answer
Enter the company codes she is responsible for in the company code organizational level in PFCG, then generate the profile. Entering * would also grant every other company code, which is more than her job requires.
Exercise
You need the same role for 20 countries, with only the company codes differing. Which approach keeps maintenance smallest?
Show answer
Create one parent role and 20 derived roles. In each derived role, maintain only the organizational values. Changes to menu or authorization objects are made once in the parent.