SAP CDS Views: Complete Beginner's Guide
Learn how to create SAP Core Data Services (CDS) views from scratch. Covers syntax, annotations, joins, and best practices for S/4HANA development.
Published June 5, 2024
Advertisement
SAP CDS Views: Complete Beginner's Guide
CDS (Core Data Services) is the backbone of modern SAP development. Every S/4HANA application and Fiori app uses CDS.
What is a CDS View?
A CDS view is a semantic layer on top of database tables. Instead of writing SELECT statements in ABAP, you define a structured data model.
Basic Syntax
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'My First CDS View'
define view entity ZI_Material
as select from MARA as _Mara
{
key _Mara.MATNR as MaterialNumber,
_Mara.MTART as MaterialType,
_Mara.MEINS as BaseUnit
}
Use our [CDS View Generator](/tools/cds-view-generator) to generate this boilerplate automatically!
Essential Annotations
Association vs Join
In CDS, prefer **associations** over JOINs for better performance:
define view entity ZI_Material
as select from MARA as _Mara
association [0..1] to MARC as _MarcData
on $projection.MaterialNumber = _MarcData.MATNR
{
key _Mara.MATNR as MaterialNumber,
_MarcData.WERKS as Plant
}
Topics: