IT CanvassTalk to an advisor
SAP examples · LessonReviewed by Anitha M, SAP Trainer, 13 yrs · Updated · Published · SAP S/4HANA 2023 · all levels

SAP CDS examples

These CDS examples show Core Data Services views, the modern SAP modeling layer, with joins, associations, aggregation and annotations that expose data to Fiori and analytics.

Quick answer

Two CDS examples: a view entity over VBAK with a 1..n association to VBAP exposing the items alongside the header, and a cube over I_SalesOrderItem with @Analytics.dataCategory, @OData.publish and @Aggregation.default annotations. The point is that annotations turn one model into an OData service, an analytical cube or UI metadata; layer base and composite views and push aggregation down.

Key takeaways
  • Watch out: Ignoring annotations that unlock OData/analytics.
  • Worked examples: a cds view with an association, aggregation and annotations, what it teaches.
  • How CDS examples fits into SAP development and the wider SAP landscape

A CDS view with an association

define view entity Z_SalesDoc as select from vbak
  association [1..*] to vbap as _Item on vbak.vbeln = vbap.vbeln
{
  key vbak.vbeln,
  vbak.kunnr,
  _Item
}

Aggregation and annotations

@Analytics.dataCategory: #CUBE
@OData.publish: true
define view entity Z_Sales_Cube as select from I_SalesOrderItem {
  key SoldToParty,
  @Aggregation.default: #SUM
  NetAmount
}

What it teaches

CDS models data close to the database with reusable, annotated views. Annotations turn a view into an OData service, an analytical cube, or UI metadata, one model, many uses. Layer base and composite views, and push filtering/aggregation down for performance.

Common pitfalls

  • Ignoring annotations that unlock OData/analytics.
  • Monolithic views.
  • Late aggregation hurting performance.
Already working on SAP and stuck on a live ticket?Get an expert SAP developer on screen-share to finish your daily tasks with you. Deliver on time, protect your reputation and your job. Monthly support only, no task-wise plans.Task assigned · no idea where to startStill stuck · your job on the lineExpert joins your screenDelivered on timeExplore On Job Support