ERPClimb logoERPClimb
CDS Annotations for UI
Fiori & SAPUI5advanced 5 min read

CDS Annotations for UI Part 3: Annotating CAP Services for Fiori Elements

Preview · a free account unlocks the full lesson

Key takeaway

Apply the same UI vocabulary in SAP CAP: annotate entities in . cds files, separate annotations into annotation files, add value helps and texts, enable drafts, and preview Fiori elements apps on CAP services locally.

Visual overview

CDS Annotations for UI Part 3: Annotating CAP Services for Fiori Elements — learning sheetFlow: CAP service projection → annotate with @UI terms → Value lists and texts → Draft enablement → Local preview. Key ideas: SAME VOCABULARY, DIFFERENT SYNTAX; WHERE TO ANNOTATE; VALUE HELPS AND TEXTS; DRAFTS. Watch out: Annotating entities in the db layer instead of the service projection leaks UI into the data model.ERPClimb.com / FIORI / LESSON 11/14 / LEARNING SHEETCDS Annotations for UI Part 3: Annotating CAP Services forFiori Elements1 · HOW IT FLOWS1CAP serviceprojection2annotatewith @UIterms3Value listsand texts4Draftenablement5Localpreview2 · KEY IDEAS EXPLAINEDSame Vocabulary, Different SyntaxCAP services expose OData V4 with annotations fromthe same UI and Common vocabularies used by RAP.In CAP CDS you write annotate ServiceName.Entity…Where To AnnotateAnnotate the service projection, not the databaseentity, so UI stays in the service layer. Manyprojects keep UI annotations in files under the…Value Helps And Texts@Common.ValueList defines value helps againstanother entity; @Common.Text with@Common.TextArrangement shows descriptions. For…Drafts@odata.draft.enabled on an entity enables drafthandling, so Fiori elements gets Edit, Save andDiscard with locks and draft tables managed by…3 · REMEMBER · WATCH OUTRememberCAP uses the same OData vocabularies; annotations are written in CDSwith the 'annotate' keyword.Keeping UI annotations in separate files (e.g. app/annotations.cds)mirrors metadata extensions.@Common.ValueList, @Common.Text and @Common.TextArrangement providevalue helps and texts.!Watch outAnnotating entities in the db layerinstead of the service projectionleaks UI into the data model.4 · IN A REAL PROJECTA CAP project annotated database entities directly, so every service exposing them inherited UI annotationsmeant for one app. Moving annotations to the service projections in app-level annotation files restoredseparation and allowed two apps with different layouts.Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Parts 1 and 2 used RAP CDS for annotations; Part 3 does the same job for CAP-based apps.

CAP services expose OData V4 using the same UI and Common vocabularies that RAP uses. In CAP CDS, you write annotate ServiceName.Entity with { ... } and use @UI.LineItem, @UI.SelectionFields, @UI.Facets and others, just with CAP's own syntax rather than RAP's.

It matters where these annotations are placed: annotating the service projection, rather than the database entity, keeps UI concerns in the service layer instead of leaking into the data model. Many projects keep UI annotations in separate files under the app folder, which keeps the service definition readable and mirrors the same idea behind RAP's metadata extensions.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.