CDS Views Part 8: DCL Access Control
Preview · a free account unlocks the full lesson
Protect CDS data with Data Control Language (DCL): access control roles that link CDS fields to PFCG authorization objects, the authorizationCheck annotation values, how ABAP SELECTs are filtered automatically, inheritance between views, and how to test and troubleshoot missing rows.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 7 made views meaningful through annotations; now we make sure each user sees only the data they're actually allowed to see, through DCL — Data Control Language — which defines row-level authorizations for a CDS view in a separate object: define role ... grant select on ... where ...
The aspect pfcg_auth is what links CDS fields to a PFCG authorization object, for example V_VBAK_VKO for sales area, so that a user only sees the rows their roles allow. Once this is in place, every SELECT on the CDS entity — whether from ABAP, OData, or analytics — is filtered automatically, with no AUTHORITY-CHECK code needed for those rows.
The @AccessControl.authorizationCheck annotation sets expectations for a given view: #CHECK means a DCL role should exist, and you get a syntax warning if it's missing; #NOT_REQUIRED means no DCL is expected, as for customizing or text views; #PRIVILEGED_ONLY means only privileged access is allowed; and #NOT_ALLOWED means a DCL role must not be defined at all. It's worth being clear that the annotation itself protects nothing — it's the DCL role that actually does the work.
A DCL role is created as a new object in ADT under Core Data Services → Access Control, with syntax like define role <name> { grant select on <entity> where <condition>; }.
The condition can be a literal (Country = 'DE'), based on the user ($session.user or a user aspect), or based on a PFCG aspect — for example, ( SalesOrganization, DistributionChannel, Division ) = aspect pfcg_auth( V_VBAK_VKO, VKORG, VTWEG, SPART, ACTVT = '03' ), where the field list on the left maps to the authorization fields on the right in the same order, and ACTVT = '03' means display.
This means the same PFCG roles already used to control transactions like VA03 now control the CDS data too.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Interview questions on this topic
Referenced SAP objects
Reviewed reference pages for the objects this page mentions.
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.