ERPClimb logoERPClimb
CDS Views
Architect / Cross-trackadvanced 9 min read

CDS Views Part 8: DCL Access Control

Preview · a free account unlocks the full lesson

Key takeaway

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 sections

Visual overview

CDS Views Part 8: DCL Access Control — learning sheetFlow: Create ZI_SalesOrderAuth with SalesOrganization, DistributionChannel, Division; set authorizationCheck #CHECK → Create DCL role ZI_SalesOrderAuth with pfcg_auth on V_VBAK_VKO → Protect ZC_SalesOrderAuthList with inheriting conditions → Run a classic report as two users with different sales org authorization and compare counts. Key ideas: authorizationCheck ANNOTATION; DCL ROLE SYNTAX; PFCG ASPECT; INHERITANCE. Watch out: DCL filters silently: users without authorization get fewer rows, not an error. "Data missing" tickets are often DCL working as designed.ERPClimb.com / ARCH / LESSON 8/10 / LEARNING SHEETCDS Views Part 8: DCL Access Control1 · HOW IT FLOWS1CreateZI_SalesOrderAuthwith…2Create DCL roleZI_SalesOrderAuthwith pfcg_auth…3ProtectZC_SalesOrderAuthListwith inheriting…4Run a classicreport as twousers with…2 · KEY IDEAS EXPLAINEDAuthorizationcheck Annotation#CHECK: a DCL role should exist; syntax warning ifmissing.#NOT_REQUIRED: no DCL expected (e.g. customizing,texts).DCL Role SyntaxNew object in ADT: Core Data Services → AccessControl.define role <name> { grant select on<entity> where <condition>; }Pfcg Aspect( SalesOrganization, DistributionChannel, Division) = aspect pfcg_auth( V_VBAK_VKO, VKORG, VTWEG,SPART, ACTVT = '03' )Field list on the left maps to authorizationfields on the right in the same order.InheritanceEach CDS entity needs its own role — a consumptionview does not automatically inherit protectionfrom the view below.Use grant select on ZC_X where inheritingconditions from entity ZI_X to reuse rules.3 · REMEMBER · WATCH OUTRememberDCL (Data Control Language) defines row-level authorizations for CDSviews in a separate object: define role … grant select on … where …aspect pfcg_auth links CDS fields to a PFCG authorization object (e.g.V_VBAK_VKO for sales area); the user sees only rows their roles allow.Every SELECT on the CDS entity — from ABAP, OData or analytics — isfiltered automatically; no AUTHORITY-CHECK code needed for those rows.!Watch outDCL filters silently: users withoutauthorization get fewer rows, not anerror. "Data missing"tickets are often DCL working asdesigned.4 · IN A REAL PROJECTAfter go-live in 8 markets, the Brazil sales team saw German orders in a custom Fiori list. The CDS view had@AccessControl.authorizationCheck: #CHECK but nobody had created the DCL role — the annotation alone protectsnothing. The team added a DCL role mapping sales area to V_VBAK_VKO, added inheriting roles for all…Original ERPClimb learning sheet • Verify against your SAP release and edition

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.

Free account

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

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.