ABAP · Intermediate · Configuration
How to configure ABAP CDS DCL access control with a PFCG authorization aspect
Limit a custom read-only sales-area data view to organizational values held in the reader's authorization role, and prove the restriction with positive and negative test users.
- APPLICABILITY
- SAP S/4HANA on-premise or Cloud Private Edition with ABAP CDS view entities and classic PFCG authorization administration. Check ABAP platform release and supported CDS syntax. Public Edition and ABAP Cloud use different authorization administration; this PFCG lab does not target them.
- TOOLS / TRANSACTIONS
- Eclipse ADT · SU21 · PFCG · SU01 · CDS DCL
Your project assignment
A hypothetical sales reporting application must show users only the rows belonging to their authorized sales organization. A developer implements DCL for ZI_TrainingSales and the security team assigns different sales organization values to two QA identities. The lab is complete only after testing both identities, not just the developer account.
Where to start: URLs and transactions
- Development tool
- Eclipse ADT
- Security transactions
- SU21, PFCG, SU01
- ERPClimb prerequisite
- How to create a role in PFCG and check it with SU53
Prerequisites
- A development package and transport plus an activated custom CDS view entity with a SalesOrg element.
- An approved authorization design and security administrator able to create a sandbox role and users.
- Non-sensitive test data for two sales organizations; a read-only test report using ABAP SQL.
Configuration workflow
CDS row authorization from role to query result
All steps visible. Play or advance one stage at a time.
Hands-on implementation — step by step
Follow the screen navigation, replace example values with approved project values, and mark each step after checking its result. The screens below are original teaching aids, not live SAP screenshots. Progress is local to this visit.
- 1
ADT → CDS data definition
Open the approved view entity and verify the exposed organizational key. Set the authorization check annotation to CHECK; activate after reviewing the data model and transport.
ADT → CDS data definitionERPClimb · illustrative screen - View entity
ZI_TrainingSales (hypothetical)- Element
SalesOrg- Annotation
@AccessControl.authorizationCheck: #CHECK
Expected result: The CDS entity activates and exposes the organizational element.
Why this matters: A check annotation alone does not supply a restriction; a matching active access control is necessary.
- 2
SU21 → approved authorization object
Ask the security administrator to create or reuse an approved object containing the organizational field and display activity. Confirm the actual field mapping before creating the DCL.
SU21 → approved authorization objectERPClimb · illustrative screen - Object
Z_SALESORG (hypothetical)- Fields
VKORG, ACTVT- Activity
03 (display)
Expected result: The object and its fields exist in the test system.
Why this matters: The DCL aspect must refer to fields actually defined on the authorization object.
- 3
ADT → New Access Control
Create a DCL source for the CDS entity. Choose the PFCG aspect template where available and adapt its identifiers to the approved object, field and view element.
ADT → New Access ControlERPClimb · illustrative screen - Role
ZR_TrainingSales- Mapping annotation
@MappingRole: true- Condition
where ( SalesOrg ) = aspect pfcg_auth( Z_SALESORG, VKORG, ACTVT = '03' );
Expected result: The access control activates successfully with a grant select on ZI_TrainingSales.
Why this matters: The aspect maps the organizational value held in the authorization to the corresponding CDS element.
- 4
PFCG → role authorization maintenance
Create two isolated test roles with the same access to the read-only report but different authorized sales organizations. Generate profiles and arrange user comparison using the normal security process.
PFCG → role authorization maintenanceERPClimb · illustrative screen - Role A / VKORG
Z_TRAIN_SALES_A / 1000- Role B / VKORG
Z_TRAIN_SALES_B / 2000- ACTVT
03 for both
Expected result: Each test identity receives only its assigned organizational value.
Why this matters: Different role values create the controlled comparison needed to validate row filtering.
- 5
QA → execute the same ABAP SQL report
Sign in as each test user and run the same read-only SELECT against the protected entity. Compare returned organization values and expected row counts without using privileged access.
QA → execute the same ABAP SQL reportERPClimb · illustrative screen - Data fixture
One approved test row per sales organization- Expected user A
Only 1000- Expected user B
Only 2000
Expected result: The two runs return distinct permitted row sets.
Why this matters: A query executed with the developer's broad permissions cannot establish restricted business-user access.
- 6
QA → negative test and evidence
Use a third test identity with report access but without the relevant object authorization. Review all other active DCL rules and consumers before recording the result.
QA → negative test and evidenceERPClimb · illustrative screen - Expected negative test
No authorized rows- Evidence
Role values and sanitized query results
Expected result: The negative test returns no restricted data and the results are documented.
Why this matters: Additional grants or privileged access may change the outcome; both must be considered in an authorization review.
Project acceptance checklist
Use this checklist to prepare evidence for your project lead.
0 of 4 checks marked. This does not certify the SAP configuration.
Validate your configuration
- ADT syntax and activation checks are clean for the CDS and DCL sources.
- Two scoped test users return only permitted sales organizations and the negative test reveals no restricted rows.
Common errors and what to check
all rows are visible.
Check: Check for missing or inactive DCL, privileged access and additional grants.
no rows for an authorized user.
Check: Compare ACTVT and organizational values with the role's generated profile.
DCL syntax error.
Check: Verify the entity element, authorization object and authorization field names.
another consumer exposes rows.
Check: Review its own access control; do not assume protection is inherited through every view.
More in the SAP Library
Need help with a configuration error? Open ERPClimb Copilot.
Technical references & further reading
Official documentation for technical verification, release compatibility and further study.