Parameterize a reusable filter
Different reports may need orders from different dates. A CDS input parameter lets a consumer provide that value rather than hard-coding it into the view.
define view entity ZI_DISPATCH_SINCE
with parameters p_since : abap.dats
as select from zdispatch_order
{
key dispatch_order as DispatchOrder,
created_at as CreatedAt
}
where created_at >= $parameters.p_since;
Parameters describe inputs to a modeled query; they do not replace authorization. A caller can pass a different date, but the application must still control which rows the user is allowed to see.
CDS access control (DCL)
CDS access control defines read-access rules in a separate DCL role. A rule can use an authorization object and its fields; when the CDS entity is read through ABAP SQL, the configured access condition can restrict rows.
@MappingRole: true
define role ZR_DISPATCH_SINCE {
grant select on ZI_DISPATCH_SINCE
where (CarrierCode) = aspect pfcg_auth(Z_DISPATCH, CARRIER, ACTVT = '03');
}
This simplified syntax is not a complete authorization design. Check whether the entity has @AccessControl.authorizationCheck configured appropriately, that the authorization object/field mapping is real, and that your role assignments are correct. ABAP SQL itself does not magically enforce every application’s business authorization; security design must be verified in the target system.
Practice
Complete the CDS parameter reference and add the DCL role/rule fragments. No ABAP output statement applies to these DDL/DCL sources. This checker only matches text patterns; it does not validate authorization or grant access.
Sources
- SAP Samples, CDS View Entities
- SAP Samples, Authorization Checks and CDS Access Control
- SAP Help Portal, ABAP CDS access control
Version note: CDS parameters, DCL aspects, authorization objects, and runtime access-check behavior are release- and deployment-dependent.
Developer practice · ABAP
Practice: declare a date parameter and DCL role
Add the date parameter reference to the view filter. Then add a DCL access rule for display activity. This is a structure exercise, not a security certification.
Complete the task using the syntax and structure described above. Variable names can differ if you use them consistently. This browser checker checks structure only; it does not compile or run ABAP.
0 required structures detected · 0 checks
Write your solution, then check its structure.
One possible solution
define view entity ZI_DISPATCH_SINCE
with parameters p_since : abap.dats
as select from zdispatch_order
{
key dispatch_order as DispatchOrder,
created_at as CreatedAt,
carrier_code as CarrierCode
}
where created_at >= $parameters.p_since;
@MappingRole: true
define role ZR_DISPATCH_SINCE {
grant select on ZI_DISPATCH_SINCE
where (CarrierCode) = aspect pfcg_auth(Z_DISPATCH, CARRIER, ACTVT = '03');
}