SAP CDS Views: Types, Syntax and Your First View Entity

Sayan Chakraborty · 31 January 2025 · 3 min read

Learn what SAP CDS views add to plain SQL, how basic, composite and consumption views fit together, and how to create and read your first view entity in ADT.

Core Data Services (CDS) views are how data is modeled in SAP S/4HANA. Fiori apps, analytical reports, OData services and RAP business objects all read their data through them, so an ABAP developer on an S/4HANA project writes and reads CDS views almost every day.

What a CDS view adds to plain SQL

A CDS view is a data model written in an SQL-like language and stored in the ABAP repository as a data definition . It runs inside SAP HANA, so filters, joins and calculations happen where the data lives, not in ABAP loops. Compared with a plain database view it adds:

• Annotations (lines starting with @ ): metadata for Fiori, analytics, security and the ABAP runtime.

• Associations : reusable relationships to other views, turned into a join only when a consumer actually uses them.

• Expressions : CASE , arithmetic, casts and aggregate functions inside the view.

• Access control : row-level authorization rules in a separate DCL object.

Basic, composite and consumption views

SAP's Virtual Data Model (VDM) stacks views in layers, and custom projects should do the same:

• Basic views sit directly on database tables and give the fields readable names.

• Composite views combine basic views and add calculations or aggregations.

• Consumption views are shaped for one app or report and carry its UI or analytics annotations.

SAP names basic and composite views I_... and consumption views C_... ; custom ones usually start with ZI_ and ZC_ . In RAP, the consumption layer is a projection view ( as projection on ).

Create your first view entity in ADT

• In ABAP Development Tools (ADT) for Eclipse, right-click your package and choose New > Other ABAP Repository Object > Core Data Services > Data Definition .

• Enter a name such as ZI_SalesOrderHeader , a description and a transport request, then pick the template Define View Entity .

• Write the view and activate it with Ctrl+F3 .

• Press F8 to open the Data Preview and check the rows.

@AccessControl.authorizationCheck: #NOT_REQUIRED

@EndUserText.label: 'Sales order header'

define view entity ZI_SalesOrderHeader

as select from vbak

association [0..1] to kna1 as _Customer

on $projection.SoldToParty = _Customer.kunnr

{

key vbeln as SalesOrder,

erdat as CreatedOn,

kunnr as SoldToParty,

@Semantics.amount.currencyCode: 'Currency'

netwr as NetValue,

waerk as Currency,

_Customer

}

Older code uses define view with @AbapCatalog.sqlViewName , which generates an extra SQL view in the ABAP Dictionary. A view entity needs no such name and activates faster, so use it for new work.

Read the view in ABAP

SELECT FROM zi_salesorderheader

FIELDS SalesOrder, NetValue, Currency,

\_Customer-name1 AS CustomerName

WHERE CreatedOn >= @lv_from

INTO TABLE @DATA(lt_orders).

The path \_Customer-name1 follows the association, so the join to KNA1 runs only in this query.

ABAP CDS or HANA CDS?

• ABAP CDS lives in the ABAP repository, is transported like any ABAP object, supports ABAP annotations and DCL authorizations, and is read by ABAP SQL, RAP and OData. This is what S/4HANA developers write.

• HANA CDS is defined directly in the SAP HANA database for native HANA applications and does not know ABAP annotations or authorizations.

Key takeaways

• Use define view entity for new views; define view with sqlViewName is the older form.

• Build in layers: basic, composite, then consumption (or a RAP projection).

• Expose associations instead of fixed joins, so each consumer reads only what it needs.

• ABAP CDS is for S/4HANA applications; HANA CDS is for native HANA development.

Want to build CDS views, OData services and RICEF objects hands-on with a trainer? See our SAP ABAP Development course .