Sub topic 2
Authorization objects, fields and activities
This chapter assumes you know what an SAP S/4HANA user is, how logon works, and what the Fiori launchpad shows. You do not need PFCG knowledge yet. The next chapter covers it.
What an authorization object is
An authorization object is a template for one kind of permission. It lists the fields that an authorization check compares. Each field describes one dimension of the permission, such as which company code or which action.
Take the standard object F_BKPF_BUK, which protects accounting documents by company code. It has two fields:
| Field | Meaning | Example value |
|---|---|---|
| `BUKRS` | Company code | `1010` |
| `ACTVT` | Activity | `03` |
A user does not own the object itself. A user owns authorizations, which are instances of the object with concrete field values. One user can hold many authorizations of the same object, for example one for company code 1010 with display access and one for 2000 with change access.
Activities
The field ACTVT holds the activity. Many objects use it, and the values are shared across them.
| Value | Activity |
|---|---|
| `01` | Create or generate |
| `02` | Change |
| `03` | Display |
| `06` | Delete |
| `16` | Execute |
Not every object supports every activity. The object's documentation lists the allowed values. In SU21, the transaction for browsing authorization objects, you can see which activities an object accepts.
How a check is evaluated
A program asks whether the user holds an authorization that covers the requested values. The check passes if at least one of the user's authorizations for that object satisfies every field of the check. Within one field, values can be single values, ranges, or * for all values.
The words "one authorization" matter. The system does not combine fields from different authorizations. Suppose a user holds company code 1010 with activity 03, and company code 2000 with activity 02. A request for company code 1010 with activity 02 fails, even though 1010 and 02 each appear somewhere in the user's data.
Checking an object in ABAP
The following check tests display access (03) to one company code. When sy-subrc is not 0, the user's roles do not grant it.
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'BUKRS' FIELD lv_company_code
ID 'ACTVT' FIELD '03'.
IF sy-subrc <> 0.
" The user has no display authorization for this company code.
MESSAGE e000(00) WITH 'No authorization for company code' lv_company_code.
ENDIF.Each ID ... FIELD ... line supplies one field value. If the check omits a field that the object defines, the check fails unless that field is explicitly marked DUMMY. Delivered code usually handles this for you, but custom code is where this mistake appears.
Common errors
- Assuming
*is safe. A full*inACTVTgrants delete and change along with display. Grant the activities the job requires. - Reading a missing authorization as a missing app. The launchpad tile can appear while the app still fails on the first check. Tile visibility and data authorization are separate layers, covered in later chapters.
- Mixing fields across authorizations when reasoning about access. Evaluate each authorization separately.
- Writing a custom check that leaves out a field of the object. The check then returns a non-zero
sy-subrcfor every user.
Exercise
A user holds two authorizations for FBKPFBUK. The first has BUKRS = 1010 and ACTVT = 03. The second has BUKRS = 2000 and ACTVT = 02. Does an authority check for BUKRS = 1010 and ACTVT = 02 pass?
Show answer
No. The check passes only if a single authorization matches every field. The first authorization has the right company code but only display activity. The second has the right activity but a different company code. The fields are not combined across authorizations, so sy-subrc is not 0.
Exercise
Which activity value does a read-only user need on most objects, and why is granting ACTVT = * a poor choice for that user?
Show answer
Activity 03 (display). ACTVT = * also covers create, change and delete, so the user could modify data that they should only read.