ERPClimb logoERPClimb
CDS Annotations
RAP / CDS / ODatabeginner 9 min read

CDS Annotations Part 1: What Annotations Are and Where They Apply

Free sample lesson · open to everyone

Key takeaway

Understand what CDS annotations are, where they can be placed, which families exist (ABAP, semantics, UI, consumption, search, analytics), how they propagate through view layers and where they end up in OData.

In this lessonShow sections

Expert visual walkthrough

RAP · CDS · ODATA ACADEMY · Architecture hierarchyERPClimb.com

What Annotations Are and Where They Apply

CDS Annotations · Chapter-specific technical teaching map

Architecture hierarchy

1Top level

Data model annotations

2Related level

Metadata extensions

3Related level

Propagation and overrides

4Related level

Consumer interpretation

Tutor's chapter takeaway

Understand what CDS annotations are, where they can be placed, which families exist (ABAP, semantics, UI, consumption, search, analytics), how they propagate through view layers and where they end up in OData.

In a real project

A team put all UI annotations, semantic annotations and search annotations directly into their interface views because "that is where the fields are". When a second app reused the interface view, it inherited list columns and…

Watch out for

• Treating annotations as if they changed the data returned. • Placing annotations at the wrong scope and ignoring the warning. • Putting app-specific UI annotations into reusable interface views. • Repeating propagated…

Conceptual study map, not an SAP configuration screenshot or a guaranteed runtime sequence. Consult the lesson for implementation prerequisites and exceptions.

The situation: a real project scenario

A team put all UI annotations, semantic annotations and search annotations directly into their interface views because "that is where the fields are". When a second app reused the interface view, it inherited list columns and labels designed for the first app, and nobody could change one app without affecting the other.

They reorganized: semantics (currency, units, texts) stayed in interface views because they describe the data; UI and search annotations moved into metadata extensions of each app's projection. The ADT Active Annotations view was used to verify the effective result per view.

Explanation

This series covers CDS annotations across five parts: this lesson covers what annotations are and where they apply; Part 2 covers semantic annotations for currency, units, texts and admin fields; Part 3 covers Fiori UI annotations like line items, facets and selection fields; Part 4 covers metadata extensions and separating UI from the data model; and Part 5 covers troubleshooting precedence, metadata and UI behavior.

A CDS view defines data, but annotations describe that data for the tools and frameworks that consume it: stating that a decimal is an amount in the currency named by another field leads to correct formatting and aggregation; marking a field to show as the first column of a list gets it rendered that way by Fiori Elements; declaring that authorization must be checked sets up access control; and marking an element as searchable enables free-text search.

The database itself ignores all of this — it's the frameworks that read annotations from the CDS metadata.

Annotations can only be placed at certain scopes. Entity, or header, annotations go before "define view entity" — things like @EndUserText.label, @AccessControl.authorizationCheck, @UI.headerInfo, @Search.searchable, and @Metadata.allowExtensions. Element annotations go before a specific element, such as @Semantics.amount.currencyCode, @UI.lineItem, or @Consumption.valueHelpDefinition. Parameter annotations go before a parameter, such as @Environment.systemField or @Consumption.defaultValue. Placing an annotation at the wrong scope either produces a syntax warning or simply gets ignored, and ADT's code completion shows which annotations are valid at each position.

The main annotation families are worth knowing by name. The ABAP or core family includes @AbapCatalog for classic views, @AccessControl, @EndUserText, and @Metadata. The semantics family, @Semantics.*, covers amounts, quantities, units, currency codes, texts, languages, and admin fields. The object model family, @ObjectModel.*, covers text elements and associations, representative keys, usage type, and data category.

The UI family, @UI.*, drives Fiori Elements layout — headerInfo, lineItem, identification, facet, fieldGroup, selectionField, hidden. The consumption family, @Consumption.*, covers value helps, default values, filter behavior, and hiding fields in consumption. The search family, @Search.*, covers searchable entities, default search elements, and fuzziness. And the analytics family, @Analytics.* and @AnalyticsDetails.*, covers cubes, dimensions, and queries.

Propagation through layers matters a great deal: by default, an element annotation on one view is also visible, for that same element, in views built on top of it. @Semantics.amount.currencyCode declared on an interface view, for instance, is already known in the consumption view without needing to be repeated.

Header annotations, by contrast, are never propagated. @Metadata.ignorePropagatedAnnotations: true stops propagation into a given view, and a value defined directly on a view, or in its metadata extension, always overrides a propagated one. ADT's "Active Annotations" view shows the effective annotation for each element and exactly where it comes from.

In a RAP service, the relevant annotations on the exposed projections end up translated into OData vocabularies inside $metadata — UI.LineItem, Common.Text, Measures.ISOCurrency, and so on — and that's exactly where Fiori Elements reads them from.

With this foundation, an annotated view can be read and matched to the framework that actually uses each annotation. Part 2 starts with the most important family: semantics.

Code example

ABAP Code
// ===== Annotation scopes in one view =====@EndUserText.label: 'Sales Order'                        // header: ABAP/core@AccessControl.authorizationCheck: #CHECK                // header: access control expected@Metadata.allowExtensions: true                          // header: metadata extensions allowed@Search.searchable: true                                  // header: search frameworkdefine view entity ZI_SalesOrder  with parameters    @Environment.systemField: #SYSTEM_DATE              // parameter annotation    p_keydate : abap.dats  as select from zso_head{      @Search.defaultSearchElement: true                  // element: search  key sales_order     as SalesOrder,       @EndUserText.label: 'Sold-To Party'                 // element: label      customer_id     as Customer,       @Semantics.amount.currencyCode: 'CurrencyCode'      // element: semantics      net_amount      as NetAmount,      currency_code   as CurrencyCode,       @Semantics.systemDateTime.lastChangedAt: true       // element: admin field      last_changed_at as LastChangedAt} // ===== Propagation =====// A view on top of ZI_SalesOrder does NOT need to repeat// @Semantics.amount.currencyCode for NetAmount - it is propagated.//// define view entity ZC_SalesOrderAnalysis//   as select from ZI_SalesOrder( p_keydate: $session.system_date )//   { key SalesOrder, NetAmount, CurrencyCode }   // NetAmount still knows its currency//// Stop propagation (rarely needed)://   @Metadata.ignorePropagatedAnnotations: true // ===== In OData $metadata (V4), for example =====//   <Annotation Term="Measures.ISOCurrency" Path="CurrencyCode"/>//   <Annotation Term="Common.Label" String="Sold-To Party"/>

Watch out

Common mistakes

  • Treating annotations as if they changed the data returned.
  • Placing annotations at the wrong scope and ignoring the warning.
  • Putting app-specific UI annotations into reusable interface views.
  • Repeating propagated annotations unnecessarily, or not knowing where a value comes from.
  • Using classic @AbapCatalog.sqlViewName in new view entities.

Do this

Best practices

  • Semantics in interface views; UI in metadata extensions of projections.
  • Use ADT code completion and the Active Annotations view.
  • Always label entities and key elements with @EndUserText.label.
  • Set @Metadata.allowExtensions: true on projections that get metadata extensions.
  • Check the resulting OData $metadata when UI behavior is unexpected.

In the interview

Interview angle

Questions: "What are CDS annotations?", "What scopes exist?", "What is annotation propagation?", "Where should UI annotations live?"
Strong answer: annotations are metadata read by frameworks, not by the database; scopes are entity, element and parameter; families include semantics, object model, UI, consumption, search and analytics. Element annotations propagate to views on top unless overridden or ignored. Semantic annotations belong in interface views; UI annotations in metadata extensions of consumer projections.

Practice this lesson

Quick check

0 of 3 questions attempted

Question 1 of 3

Which statement about CDS annotation propagation is correct?

Practise this in an interview

Answer in your own words and get instant feedback, the way an interviewer would judge it.

1What are CDS annotations, which scopes and families exist, and how do they propagate?

2You inherit CDS views full of annotations. What do you review first?

See it in code

Each example starts from a requirement, shows the design, then the code step by step with a plain-language explanation of every part.

Was this lesson helpful?

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.