CDS Fundamentals
What is a CDS view, and how is it different from a classic database view?
Core Data Services views define data models in DDL source code that the ABAP runtime translates into database views with rich semantics. Unlike classic SE11 views, CDS views carry annotations, associations, parameters, and access control, and they are the foundation of Fiori, OData, and analytics on S/4HANA. One source, multiple consumers.
What are the layers of CDS: basic, composite, consumption?
Basic interface views sit directly on tables and expose raw fields. Composite views build business logic on top of interface views with joins and calculations. Consumption views add UI and OData annotations for Fiori consumption. SAP's VDM (Virtual Data Model) follows this layering — interviewers want to hear you respect the layering instead of querying tables directly.
What is the difference between define view and define view entity?
DEFINE VIEW is the classic CDS DDL creating a database view. DEFINE VIEW ENTITY (ABAP CDS) creates a CDS entity usable in RAP business objects with managed scenarios, draft handling, and behaviors. New RAP development uses view entities; classic views remain for read-only analytics. Mixing them up is a common interview tripwire.
Key takeaway: View entities power RAP and transactional apps; classic views power read-only reporting. Choose by consumer, not by habit.
Annotations
What are the most important CDS annotation categories?
UI annotations (@UI.lineItem, @UI.fieldGroup) drive Fiori elements layouts. OData annotations (@OData.publish) expose the view as a service. Analytics annotations (@Analytics.dataCategory) mark cubes and queries. Semantics (@Semantics.amount.currencyCode) connect amounts to currencies. ObjectModel annotations (@ObjectModel.text.element) wire up text associations.
How do @UI annotations turn a CDS view into a Fiori elements app?
A consumption view annotated with @UI.headerInfo, @UI.lineItem positions, and @UI.facet definitions gives Fiori elements everything to render a list report and object page with zero UI code. The metadata-only approach means UI changes are annotation changes. This is the fastest path from CDS to a working app.
What is @MetadataExtension and when do you need it?
UI annotations live in a separate metadata extension view (DEFINE VIEW ... with @MetadataExtension) layered over the consumption view. This separation keeps data logic and UI semantics independently maintainable and lets one data view serve multiple UIs. Forgetting the extension layer and stuffing UI annotations into the data view is a design smell.
Associations, Joins, and Parameters
Association vs join in CDS — when do you use which?
Associations define reusable, on-demand relationships resolved only when the consumer requests those fields — lazy and efficient. Joins materialize the relationship in the view's result set eagerly. Rule of thumb: associations for navigation paths consumers may or may not follow, joins when the related data is always needed. Associations also enable path expressions in consumers.
What are CDS parameters and how are they consumed?
Parameters (WITH PARAMETERS p_date : abap.dats) make views input-dependent, typically for date-sensitive logic like exchange rates or validity periods. OData consumers pass them as part of the entity set call, and other CDS views pass them through parameter mapping. They turn static views into reusable, context-aware building blocks.
define view entity ZI_Sales
with parameters P_KeyDate : abap.dats
as select from vbak as h
association [0..*] to ZI_SalesItem as _Items
on $projection.Vbeln = _Items.Vbeln
{
key h.vbeln as Vbeln,
_Items
} where h.erdat <= $parameters.P_KeyDate
How do path expressions work with associations?
Path expressions like _Items.NetValue let consumers reach through associations without explicit joins, and the framework generates the SQL. They work in CDS consumers, in ABAP SQL, and in OData $expand. This is why well-modeled associations beat ad-hoc joins for maintainability.
Key takeaway: Associations are lazy navigation; joins are eager. Prefer associations, expose parameters for context, and let consumers decide what to follow.
Access Control and Advanced Concepts
What is DCL and how does it secure CDS views?
The Data Control Language defines access control rules (DEFINE ROLE) granting read access based on authorization objects or PFCG aspects. DCL is evaluated at the database level, so unauthorized rows never leave HANA. Every production CDS view serving business data should have DCL — "the Fiori role handles it" is not a complete answer.
What are virtual elements in CDS?
Virtual elements are fields calculated in ABAP at runtime via a class implementing the calculation exit, declared with @ObjectModel.virtualElement. They handle logic SQL cannot express — like calling a function module — but they cannot be filtered or sorted at the database level. Use sparingly; they break push-down.
How do you expose a CDS view as an OData service?
Annotate the consumption view with @OData.publish: true and the framework generates a Gateway service from it. For full RAP services, define a service definition (DEFINE SERVICE) binding the business object's entities. The first is quick read-only exposure; the second is the transactional RAP path with behaviors and drafts.
What CDS performance pitfalls should you avoid?
Selecting unused fields through deep association chains, virtual elements in list reports, and parameters ignored by consumers all kill performance. Check the SQL generated via ST05 or the ADT data preview's SQL console, keep aggregations in the database, and prefer key-based access. Code push-down is the mantra: compute in HANA, not in ABAP loops.
What is the difference between a CDS table function and a view?
A table function is implemented in SQLScript (or AMDP) and called like a view, used when logic exceeds what CDS DDL can express — complex procedural calculations, for example. Views are pure DDL and fully optimizable by the HANA engine. Reach for table functions only when DDL genuinely cannot do the job.
Interviewing soon? Drop your toughest CDS question in the comments.