Explain annotations in CDS: scopes, propagation and metadata extensions. When do you use a metadata extension?
Say your answer out loud first.
Practise another way
Annotations add metadata at entity, element or parameter level. Where an annotation may be used is set by its @Scope. Element annotations are propagated to views that select the elements, unless I set Metadata.ignorePropagatedAnnotations.
A metadata extension is a separate DDLX object, ANNOTATE ENTITY, that adds or overrides annotations without touching the view. It needs Metadata.allowExtensions and a layer, and it cannot add fields. I use it for UI annotations.
Scopes. An annotation is defined with define annotation and a @Scope such as #ENTITY, #VIEW, #ELEMENT, #PARAMETER, #EXTEND_VIEW. The syntax check and ADT only accept an annotation where its scope allows it, and a main annotation can appear once per scope.
Framework annotations (@UI, @Semantics, @ObjectModel) are read by the frameworks that use them; ABAP annotations (@AccessControl, @EndUserText, @AbapCatalog) by the ABAP runtime.
Propagation. If a view entity selects an element from another view entity, the element annotations come along. SAP's example: @Semantics.amount.currencyCode does not have to be repeated in the consumption view.
Only element annotations propagate, never entity annotations. @Metadata.ignorePropagatedAnnotations: true switches it off; then a mandatory annotation that was inherited, like the currency code link, is missing and the check reports an error.
Metadata extensions (MDE). A DDLX object:
@Metadata.layer: #CUSTOMER
annotate entity ZC_Travel with
{
@UI.lineItem: [{ position: 10 }]
@UI.selectionField: [{ position: 10 }]
AgencyID;
}
Rules:
- The target needs
@Metadata.allowExtensions: true. @Metadata.layeris mandatory:#CORE,#LOCALIZATION,#INDUSTRY,#PARTNER,#CUSTOMER, with#CUSTOMERwinning. Two MDEs in the same layer for the same annotation cause a warning and the first found is used.- You can only address existing elements; new elements need a view extension.
- Only annotations flagged as allowed in MDEs can be used (mostly UI, analytics, search).
- MDEs affect annotation evaluation by frameworks (for example Fiori elements metadata), not the SQL or activation of the view.
When to use one. Keep UI annotations out of the model view so the data model stays clean, let a partner or customer override SAP's UI metadata without modification, or keep one annotation set per app.
In RAP projections, UI annotations normally live in an MDE.
Distinguishes scope, propagation and MDE with their exact rules (element-only propagation, layer priority, no new elements) and says when each applies.
Describes annotations as 'comments for Fiori' and thinks a metadata extension can add fields or change the SQL.
Expecting metadata extensions to add fields or change runtime selection. They only add or override annotation metadata for existing elements.
- What happens if two MDEs in the same layer annotate the same element?
- How do you stop a currency annotation from being inherited?
- Can an MDE change an element's data type?
- Why put @UI annotations in an MDE instead of the view?
4 official pages and 2 prep guides. Confidence: high. Checked 21 Nov 2026.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Prep guide Gives the question.
- Prep guide Gives the question.