ERPClimb logoERPClimb
CDS Views
Architect / Cross-trackintermediate 9 min read

CDS Views Part 7: Annotations for Semantics, Texts, Search and UI

Preview · a free account unlocks the full lesson

Key takeaway

Use CDS annotations to give data meaning: currency and unit semantics, text views and text associations, language-dependent descriptions, search annotations, UI annotations for Fiori elements, and metadata extensions that keep UI layout out of the data model.

In this lessonShow sections

Visual overview

CDS Views Part 7: Annotations for Semantics, Texts, Search and UI — learning sheetFlow: Create text view ZI_SalesOrderTypeText over TVAKT → Create consumption view ZC_SalesOrderList with a text association and filtered path for the order type name → Add search annotations; allow metadata extensions → Create a metadata extension with lineItem and selectionField annotations. Key ideas: ANNOTATION BASICS; SEMANTIC ANNOTATIONS; TEXT VIEWS AND TEXTS; SEARCH. Watch out: Annotations have scopes — view level, element level, parameter level. A misspelled or wrongly placed annotation often gives only a warning, and the app silently ignores it.ERPClimb.com / ARCH / LESSON 7/10 / LEARNING SHEETCDS Views Part 7: Annotations for Semantics, Texts, Searchand UI1 · HOW IT FLOWS1Create text viewZI_SalesOrderTypeTextover TVAKT2Createconsumption viewZC_SalesOrderList…3Add searchannotations;allow metadata…4Create ametadataextension with…2 · KEY IDEAS EXPLAINEDAnnotation BasicsSyntax: @Namespace.annotation: value, placedbefore the view or before a field.Common namespaces: EndUserText, Semantics,ObjectModel, Search, UI, Consumption, Analytics,AccessControl, VDM.Semantic Annotations@Semantics.amount.currencyCode: 'CurrencyField' —amount with its currency.@Semantics.quantity.unitOfMeasure: 'UnitField' —quantity with its unit.Text Views And TextsText view: @ObjectModel.dataCategory: #TEXT, keys= code + language, one text field.In the main view: association to the text view and@ObjectModel.text.element pointing to thedescription field, or…Search@Search.searchable: true at view level enablesfree-text search (OData $search, Fiori searchfield).@Search.defaultSearchElement: true on the fieldsto search; @Search.fuzzinessThreshold for fuzzymatching.3 · REMEMBER · WATCH OUTRememberAnnotations (@…) add metadata to a view or field; the database ignoresmost of them, but frameworks (OData, Fiori elements, analytics…Semantic annotations (currency, unit, text, language) describe what afield is; UI annotations describe how an app shows it.Metadata extensions (annotate entity … with) move UI annotations intoa separate object, so the data model stays clean and layouts can be…!Watch outAnnotations have scopes — viewlevel, element level, parameterlevel. A misspelled or wronglyplaced annotation often gives only awarning, and the app silentlyignores it.4 · IN A REAL PROJECTA Fiori list report built on a custom CDS view showed order types only as codes (TA, ZOR) and labels like"AUART". Users kept a printed code list next to the screen. The developer added a text view overTVAKT, a text association with @ObjectModel.text.element, and @EndUserText labels. UI annotations were moved…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 5 introduced consumption views; now we make them meaningful for Fiori, search, and value helps. Annotations — written as @Namespace.annotation: value and placed before a view or before a field — add metadata that the database itself mostly ignores, but that frameworks like OData, Fiori elements, analytics, and search actively read.

Common namespaces include EndUserText, Semantics, ObjectModel, Search, UI, Consumption, Analytics, AccessControl, and VDM, and ADT's code completion (Ctrl+Space) will show which annotations are valid in a given scope.

It's worth noting that annotations have distinct scopes — view level, element level, parameter level — and a misspelled or misplaced annotation often produces only a warning, with the app then silently ignoring it.

Semantic annotations describe what a field actually is, independent of how it's displayed: @Semantics.amount.currencyCode: 'CurrencyField' pairs an amount with its currency, @Semantics.quantity.unitOfMeasure: 'UnitField' pairs a quantity with its unit, @Semantics.language: true and @Semantics.text: true mark fields in text views, and @EndUserText.label / quickInfo supply the field labels shown in apps.

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
  • Code example
  • 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.