ERPClimb logoERPClimb
CDS Views
RAP / CDS / ODatabeginner 11 min read

CDS Views Part 1: What a CDS View Entity Is and Why It Matters

Free sample lesson · open to everyone

Key takeaway

Understand what a CDS view entity is, how it differs from a classic DDIC-based CDS view, which layers (VDM) it lives in, and how ABAP, RAP, OData and analytics all consume the same model.

In this lessonShow sections

Expert visual walkthrough

RAP · CDS · ODATA ACADEMY · Architecture hierarchyERPClimb.com

What a CDS View Entity Is and Why It Matters

CDS Views · Chapter-specific technical teaching map

Architecture hierarchy

1Top level

Database sources

2Related level

CDS view entity

3Related level

Associations and semantics

4Related level

RAP or SQL consumer

Tutor's chapter takeaway

Understand what a CDS view entity is, how it differs from a classic DDIC-based CDS view, which layers (VDM) it lives in, and how ABAP, RAP, OData and analytics all consume the same model.

In a real project

A finance team had five custom ABAP reports that each selected sales orders from tables, joined customers and calculated the order age and status text in ABAP loops. The logic differed slightly between reports, so the numbers…

Watch out for

• Creating new classic CDS views with @AbapCatalog.sqlViewName instead of view entities. • Treating CDS as a copy of the table: keeping cryptic column names and no semantics. • Putting all logic into one huge view instead of…

Conceptual study map, not an SAP configuration screenshot or a guaranteed runtime sequence. Consult the lesson for implementation prerequisites and exceptions.

The situation: a real project scenario

A finance team had five custom ABAP reports that each selected sales orders from tables, joined customers and calculated the order age and status text in ABAP loops. The logic differed slightly between reports, so the numbers never matched, and one report took 12 minutes because it read all orders into ABAP before filtering.

The team built one interface view ZI_SalesOrder with the status text, age calculation and customer association, and a consumption view per report. The reports became simple SELECTs with WHERE clauses that run on HANA. Runtime of the slowest report dropped to seconds, all reports showed identical figures, and the same view was later reused for a Fiori app without rewriting the logic.

Explanation

This series covers CDS view entities across four parts: this lesson covers what a CDS view entity is and why it matters; Part 2 builds a first one in ADT, a sales order item view; Part 3 covers performance — joins, associations, filters and aggregation; and Part 4 covers authorization with DCL and clean-core data access. After this series, the natural continuation is CDS Associations and CDS Annotations, and then RAP Business Objects.

Core Data Services, or CDS, is SAP's language for defining data models directly on the database. A CDS definition is written in ADT, and on activation it becomes a database object — on SAP HANA, an SQL view — plus ABAP metadata. Whenever anyone reads it, the database executes it: joins, filters, calculations and aggregations all run where the data actually lives, which is exactly what "code pushdown" means, rather than on the ABAP application server.

A CDS view doesn't store any data of its own. It's a named, reusable query carrying business meaning: readable field names, keys, relationships through associations, semantics (this field is an amount, that one is its currency), and annotations for UI, analytics, search and authorization.

There are really two generations of this technology. The classic CDS view, written with "define view" and @AbapCatalog.sqlViewName, creates an additional DDIC SQL view on activation — this is the older approach and is obsolete for new development.

The CDS view entity, written with "define view entity", needs no separate DDIC SQL view, activates faster, enforces stricter and cleaner syntax checks, and forms the basis for RAP and ABAP Cloud. New development should always use view entities; existing classic views keep working and can be migrated with an ADT tool whenever they're touched.

A view entity has several parts. Header annotations cover things like the label and access control, via @AccessControl.authorizationCheck. The data source is declared with "as select from" — a table, another CDS view, or a join.

Associations declare relationships to other views, such as "association [0..1] to ZI_Customer as _Customer", and are only actually joined when a consumer uses them, a topic covered in the CDS Associations series. The element list, inside the braces, lists the fields, renamed to CamelCase business names with "as", with keys marked using "key".

Expressions can include CASE, CAST, arithmetic, string and date functions, and calculated fields. Element annotations, such as @Semantics.amount.currencyCode, connect an amount to its currency. And optionally, a view can have parameters (declared "with parameters"), WHERE conditions, and GROUP BY for aggregation.

SAP organizes CDS views in layers, forming what's called the Virtual Data Model, or VDM — which is why the I_, C_ and R_ prefixes show up everywhere, and why projects tend to copy the idea.

Basic or interface views (I_) represent one business entity close to the table, with clean names, keys and associations, reused everywhere — I_SalesOrder and I_Currency are examples. Composite views combine basic views for a particular purpose, such as an item combined with product and customer data.

Consumption views (C_) are shaped for one specific app or report, carrying UI or analytics annotations. And RAP base BO views (R_) are the root and child views of a transactional business object, covered in the RAP Business Objects series.

Released SAP views, carrying a release contract, are the stable way to read SAP data in ABAP Cloud and clean-core development, as covered in Part 4.

A CDS view gets consumed in several ways: by ABAP code directly, with SELECT ... FROM zi_salesorderitem treating it like a table; by RAP, through the base and projection views of business objects, with OData services generated from them; by Fiori Elements, through OData and UI annotations; by analytics, through analytical queries and embedded analytics built on CDS cubes; and by enterprise search and other frameworks, through their own annotations. One model serving many consumers is really the whole point of CDS.

It's worth being clear about what CDS is not. It's not a place for transactional logic — creates and updates belong to RAP business objects, not to CDS views themselves. It's not a cache — every read runs against the database live. And it's not automatically fast — a badly designed stack of views can still be slow, as covered in Part 3.

The code example is worth reading closely: a view entity over a sales-order header table with renamed fields, a CASE expression turning a status code into readable text, a calculated field, an association to a customer view, and semantic annotations — with an ABAP SELECT at the bottom reading it exactly like a table. Part 2 builds a similar view step by step in ADT.

After Part 1, there's a clear picture of what a CDS view entity actually is, where it sits in the bigger picture, and why RAP, Fiori and analytics all build on top of it.

Code example

ABAP Code
// ===== A typical CDS view entity (sales order header) =====@AccessControl.authorizationCheck: #CHECK                // declares a DCL role must grant access, or all rows are blocked@EndUserText.label: 'Sales Order'define view entity ZI_SalesOrder  as select from zso_head  association [0..1] to ZI_Customer as _Customer          // to-one link; joined only when a consumer actually uses _Customer    on $projection.Customer = _Customer.Customer{  key sales_order          as SalesOrder,      customer_id          as Customer,      sales_org            as SalesOrganization,      order_date           as OrderDate,       // readable text instead of a code      case overall_status        when 'A' then 'Open'        when 'B' then 'In Process'        when 'C' then 'Completed'        else 'Unknown'      end                  as OverallStatusText,       @Semantics.amount.currencyCode: 'CurrencyCode'      // ties NetAmount to its currency field for correct formatting/conversion      net_amount           as NetAmount,      currency_code        as CurrencyCode,       // calculated field, executed on the database      cast( dats_days_between( order_date, $session.system_date ) as abap.int4 )                           as AgeInDays,       _Customer                                           // exposes the association so consumers can $expand or use path expressions} // Classic (obsolete) style for comparison - do not use for new development:// @AbapCatalog.sqlViewName: 'ZISOHEAD'// define view ZI_SalesOrder_Old as select from zso_head { ... } " ===== Consuming the view in ABAP =====SELECT SalesOrder, OverallStatusText, NetAmount, CurrencyCode, AgeInDays  FROM zi_salesorder  WHERE SalesOrganization = '1010'    AND AgeInDays > 30  ORDER BY AgeInDays DESCENDING  INTO TABLE @DATA(old_orders)  UP TO 100 ROWS. " Path expression: read a field of the associated customer (joined only because used)SELECT SalesOrder, \_Customer-CustomerName AS CustomerName  FROM zi_salesorder  INTO TABLE @DATA(orders_with_customer)  UP TO 10 ROWS.

Watch out

Common mistakes

  • Creating new classic CDS views with @AbapCatalog.sqlViewName instead of view entities.
  • Treating CDS as a copy of the table: keeping cryptic column names and no semantics.
  • Putting all logic into one huge view instead of layering interface and consumption views.
  • Doing calculations and filtering in ABAP loops after reading everything from the view.
  • Expecting a CDS view to insert or update data — that is RAP's job.
  • Reading SAP tables directly in clean-core code instead of released CDS views.

Do this

Best practices

  • Use "define view entity" for all new CDS development.
  • Give every element a business name and mark real keys.
  • Follow a layer model: interface (I_) views reused, consumption (C_) views per use case, R_ views for RAP business objects.
  • Push filters, calculations and aggregations into CDS so the database does the work.
  • Declare relationships as associations instead of hard joins where possible.
  • Annotate amounts, quantities and texts with their semantics from the start.

In the interview

Interview angle

Typical questions: "What is CDS and why is it important?", "What is the difference between a CDS view entity and a classic CDS view?", "What is the VDM?"

Strong answer: CDS defines semantically rich data models executed on the database (code pushdown). View entities replace classic DDIC-based CDS views: no SQL view object, faster activation, stricter checks, and they are required for RAP and ABAP Cloud. Explain the layers (interface, composite, consumption, and R_ views for RAP) and name several consumers of the same model: ABAP SQL, RAP/OData, Fiori, analytics. Mention that CDS is read-only; transactions go through RAP.

Practice this lesson

Quick check

0 of 3 questions attempted

Question 1 of 3

Which statement correctly describes a CDS view entity compared to a classic CDS view?

Practise this in an interview

Answer in your own words and get instant feedback, the way an interviewer would judge it.

1Explain the virtual data model layers (interface, composite, consumption, and RAP R_ views). Why not put everything into one CDS view?

2What is a CDS view entity, and how does it differ from a classic CDS view defined with @AbapCatalog.sqlViewName?

See it in code

Each example starts from a requirement, shows the design, then the code step by step with a plain-language explanation of every part.

Was this lesson helpful?

Keep exploring

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.