CDS views and the virtual data model
How S/4HANA exposes its data through layered CDS views, and how you build your own views to find and fix bad master data.
From tables to a data model
S/4HANA still has KNA1, LFA1 and MARA, but SAP wants apps, reports and integrations to read the virtual data model (VDM) instead: layered CDS views that give the tables business names, associations, semantics and authorization checks. 'Virtual' means nothing is copied; the SQL is pushed down to HANA when the view is queried.
The view types and their prefixes
The prefix tells you what a view is for. Also check the release state (API State tab in ADT): a view released for cloud development is a stable API, and clean-core extensions (lesson 3-4) may only use released objects.
Try it: sort into layers
Put each object in its VDM layer.
The master data views you will use most
Your table knowledge transfers directly: each view keeps the grain of the table underneath. Confirm exact field names in ADT (F2 on a view name) before writing a join.
Try it: complete a view entity
Use define view entity (the modern syntax since ABAP 7.55); the old define view with sqlViewName is obsolete. This view finds organisation BPs (category '2') with no tax number.
Fill the blanks so the view lists organisation BPs without any tax number.
@AccessControl.authorizationCheck: #CHECK @EndUserText.label: 'Organisation BPs without any tax number' define ZI_BPMissingTaxNumber as select from as bp I_BusinessPartnerTaxNumber as tax on tax.BusinessPartner = bp.BusinessPartner { bp.BusinessPartner, bp.BusinessPartnerFullName } where bp.BusinessPartnerCategory = '2' and tax.BusinessPartner
Build it in ADT, step by step
CDS views live in Eclipse with ABAP Development Tools (ADT), together with RAP and service bindings. It is the first technical skill to pick up.
Aggregations: a scorecard in one view
Management wants numbers, not rows. A case turns each row into 1 or 0 and sum counts them, all inside HANA.
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Customer completeness by country'
define view entity ZI_CustomerDQByCountry
as select from I_Customer
{
key Country,
count(*) as CustomerCount,
sum( case when TaxNumber1 = '' then 1 else 0 end ) as MissingTaxNumber1
}
group by CountryIllustrative. Check field names in ADT; add an access control in a real system.
Classic access versus CDS
From a view to a work list
Add a service definition and binding, plus UI annotations, and Fiori elements generates a list report with no front-end code. The same OData service serves Python scripts or an AI agent.
Try it: pick the data source
You need a steward work list of suppliers missing purchasing-organisation data, on a clean-core S/4HANA system. What do you build your view on?
Remember
- The VDM is a layered set of CDS views over the tables; nothing is copied.
- Build on released I_ views with define view entity; C_ views serve one app.
- One CDS rule can feed a Fiori work list, a KPI and an API.