SAP ABAP CDS Essentials
Introduction to ABAP Core Data Services
A New Way to Model Data
In the world of SAP development, how you access and model data is critical. For a long time, the primary method was to define views directly in the database using the ABAP Dictionary (SE11). This worked, but it had limitations. The logic to process the data, such as calculations and aggregations, often had to be written in the application layer. This meant pulling large amounts of data from the database to the application server and then processing it, which can be inefficient.
The traditional approach meant the database was just for storage. The application server did all the heavy lifting.
Enter ABAP Core Data Services, or CDS. CDS is a modern infrastructure for defining and consuming semantically rich data models. Instead of just creating a simple view on database tables, CDS allows you to build powerful models that push the data-intensive logic down from the application server to the database itself. This is a core concept of the 'code-to-data' or 'code pushdown' paradigm, made possible by the in-memory power of SAP HANA.
CDS vs. Traditional Views
So what makes a CDS view different from a classic database view created in transaction SE11? While both provide a structured look at data from one or more tables, their capabilities diverge significantly.
| Feature | Traditional DB View (SE11) | ABAP CDS View |
|---|---|---|
| Primary Logic Location | Application Server | Database (HANA) |
| Calculations & Aggregations | Limited, mostly done in ABAP | Natively supported in the view |
| Semantic Information | Minimal | Rich, via annotations |
| Associations | Simple joins only | Complex associations and paths |
| Extensibility | Difficult to extend | Designed for extensibility |
| OData Exposure | Requires manual effort | Automatic via an annotation |
The key takeaway is that CDS views are much more than just a window into your data. They are a powerful modeling tool. They can perform calculations, aggregate data, define relationships (associations) between other views, and be enriched with metadata that describes their business purpose. This allows you to build a reusable, consistent, and performant data layer for all your applications.
Basic Structure and Annotations
A CDS view is defined using a specific Data Definition Language (DDL) syntax, which is an extension of SQL. Let's look at a simple example that defines a view for basic sales order header data.
@AbapCatalog.sqlViewName: 'Z_I_SalesOrder_H'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales Order Header Data'
define view Z_I_SalesOrder
as select from snwd_so
{
key node_key as SalesOrderID,
buyer_guid as BuyerID,
gross_amount as GrossAmount,
currency_code as CurrencyCode
}
Let's break this down. The define view statement names our CDS view (Z_I_SalesOrder). The as select from clause specifies the data source, which in this case is the database table snwd_so.
The most interesting part for now are the lines starting with @. These are called annotations.
annotation
noun
Metadata added to a CDS view to provide additional semantic information or configure its technical behavior. Annotations are framework-specific.
Annotations give the CDS view its power and flexibility. They provide metadata that different frameworks, like the ABAP runtime or OData services, can understand and use.
@AbapCatalog.sqlViewName: This is mandatory. It defines the name of the SQL view that gets created in the underlying database.@AccessControl.authorizationCheck: This tells the ABAP runtime to enforce authorization checks when the data is accessed.@EndUserText.label: This provides a human-readable description for the view, which is useful for analytics tools.
By using CDS, you're not just defining a data structure; you're creating a rich, self-describing model that's ready for modern application development.
Time to review these core ideas.
Let's check your understanding.
What is the primary advantage of the "code pushdown" paradigm enabled by ABAP CDS views?
Which of the following is a key capability of an ABAP CDS view that is NOT available in a classic SE11 database view?
You now have a foundational understanding of what ABAP CDS is and why it's a fundamental shift in how data modeling is done in the SAP ecosystem. By pushing logic down to the database and enriching models with semantic information, CDS provides a robust and performant foundation for any application.