CDS Views Part 4: Authorization with DCL and Clean-Core Data Access
Preview · a free account unlocks the full lesson
Control which rows each user may see with CDS access control (DCL): authorizationCheck values, pfcg auth conditions, inheriting roles in projections, privileged access — and read SAP data the clean-core way through released CDS views.
In this lessonShow sectionsHide sections
Visual overview
Explanation
A DCL role adds a row filter to every read of a view. If @AccessControl.authorizationCheck is set to #CHECK but no role actually exists, you only get a warning — the data stays fully open. Projections need their own role too, typically written as "inheriting conditions from entity." And in clean core, you read released views, the I_… views, never SAP tables directly.
Your sales order views already return the right data fast, as built in Parts 2 and 3, but a sales manager in sales organization 1010 must not see orders belonging to 2020. CDS solves this declaratively through access control, and this part also covers how to read SAP data the clean-core way.
CDS access control works by writing a DCL role, an Access Control object, alongside the view — something like "define role ZI_SALESORDER { grant select on ZI_SalesOrder where ... }". The condition refers to view fields and, usually, to a classic authorization object via "aspect pfcg_auth," so the user's PFCG role values for that object become a filter.
When anyone reads the view, whether through ABAP SQL, through RAP/OData, or through analytics, the database query automatically picks up that extra WHERE condition — the user simply sees fewer rows, with no error and no extra code in the app. This is row-level security defined once and applied to every consumer.
The @AccessControl.authorizationCheck annotation on the view states whether access control is expected. #CHECK means a role should exist; if none does, a syntax warning appears and the view remains readable without restriction — this suits views carrying business data. #MANDATORY means a role must exist, and reading fails outright if none is defined. #NOT_REQUIRED means no role is needed at all, which suits value helps with public data like currencies or units. #NOT_ALLOWED means access control must not be used, and any roles present are simply ignored. #PRIVILEGED_ONLY means the view is only readable with privileged access. The annotation documents the intent; the actual filtering comes from the DCL role.
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
More lessons in this topic
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.