Subject: SAP-HANA-Live | SAP Domain
In the SAP HANA Live environment, Core Data Services (CDS) Views are fundamental to enabling real-time analytics. CDS Views allow developers to define semantic layers directly on database tables, providing rich data models that support advanced reporting and analytical capabilities. Understanding the syntax and structure of CDS Views is critical for efficient use of SAP HANA Live to expose live operational data.
This article explores the core syntax elements and structural components involved in defining CDS Views within the SAP ecosystem.
Core Data Services (CDS) Views are ABAP-managed database views or HANA database artifacts that encapsulate complex data models. They provide a high-level abstraction on top of database tables and enable:
CDS Views simplify data consumption by combining data retrieval, transformation, and filtering logic into a single artifact.
A typical CDS View definition consists of the following components:
Here’s a simplified syntax template for defining a basic CDS View:
@AbapCatalog.sqlViewName: 'ZCDS_EXAMPLE'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Example CDS View'
define view ZCDS_ExampleView
as select from sflight
{
key carrid, -- Airline carrier ID
key connid, -- Connection number
fldate, -- Flight date
price,
currency
}
Annotations:
@AbapCatalog.sqlViewName specifies the technical name of the generated SQL view in the database. It must be unique and follow naming conventions (typically 8 characters).@AccessControl.authorizationCheck controls the authorization mechanism, where #NOT_REQUIRED means no authorization check for this view.@EndUserText.label provides a descriptive label visible in tools.View Declaration:
The define view keyword initiates the CDS View creation followed by the view name (e.g., ZCDS_ExampleView).
Select From Clause:
Defines the database table or another CDS View to select data from (sflight in this example).
Field List:
Lists the fields to be exposed by the view. The keyword key marks fields as part of the primary key for the view.
Associations replace traditional SQL joins in CDS Views and create reusable navigation paths between entities.
association [0..1] to scarr as _Carrier on $projection.carrid = _Carrier.carrid
This defines a one-to-zero-or-one association to the scarr table, enabling data enrichment without immediate join execution.
Parameters allow dynamic filtering in CDS Views.
define view ZCDS_FilteredView
with parameters
p_carrid : scarr.carrid
as select from sflight
where carrid = :p_carrid
{
key carrid,
key connid,
fldate,
price
}
Here, p_carrid is a parameter to filter flights by carrier ID dynamically.
Annotations provide metadata to integrate CDS Views seamlessly with SAP Fiori Elements and analytical tools.
Examples:
@Analytics.dataCategory: #CUBE marks the view for analytical purposes.@UI.lineItem controls which fields appear in UI lists.CDS Views are a powerful component of the SAP HANA Live framework, enabling real-time data modeling with rich semantics and extensibility. Mastering their syntax and structure is key to unlocking advanced reporting and analytics capabilities in the SAP ecosystem. By understanding annotations, associations, parameters, and best practices, developers can efficiently create CDS Views that serve operational and analytical needs with ease.