Sub topic 3
Restricting Analytical Data and Reusing Queries
Assume you know CDS view entities, associations, basic SQL, and SAP Fiori navigation. This chapter focuses on controlling access and reusing an analytical query in different consumers.
Restricting data with CDS access control
CDS access control uses a Data Control Language (DCL) role to add row-level restrictions. The database returns only rows allowed by the user's authorizations. The restriction applies when the CDS entity is accessed through an analytical query.
The following example restricts sales data by sales organization. SalesOrg must be exposed by the protected CDS entity.
@EndUserText.label: 'Sales organization authorization'
define role ZR_SalesItemCube {
grant select on ZI_SalesItemCube
where ( SalesOrg ) =
aspect pfcg_auth( V_VBAK_VKO, VKORG, ACTVT = '03' );
}The authorization object and field names depend on the business object and system configuration. Test both an authorized and an unauthorized user. Do not assume that hiding a field in a query protects the underlying data.
Creating queries and KPIs as a key user
A key user can often create an analytical query with the Custom Analytical Queries app. The user selects a released analytical cube, chooses dimensions and measures, adds filters, and saves a query variant. KPI tools can use a query measure, a target, and threshold values to produce a tile or card.
Key-user tools do not replace developer modeling. If a required measure, association, currency, or authorization field is missing from the cube, extend the model or request a released data source instead of duplicating calculations in every query.
Analytical apps in SAP Fiori
A Fiori KPI tile gives a compact value, such as open order amount. A report app provides dimensions, filters, charts, tables, and drill-down. Both should consume a governed analytical query so that aggregation and authorizations remain consistent.
Consuming queries outside the launchpad
External consumers can use a released query through supported interfaces such as OData, an InA-based analytical client, or SAP Analytics Cloud integration. The exact protocol depends on the query type and SAP release. Confirm that the query is released for the intended use and that the consumer propagates the user's identity or an approved technical authorization context.
Performance and extensibility practices
- Push filters and aggregation into CDS and the database.
- Model associations with correct cardinalities to avoid duplicated measures.
- Expose only fields needed by the query.
- Reuse released views and extension points instead of modifying standard objects.
- Keep calculations and authorization rules in the shared model.
Exercise
A report shows doubled sales after adding a customer association. What should you inspect first?
Show answer
Check the association cardinality and join condition. A one-to-many join can duplicate fact rows before aggregation.