CDS Annotations for UI Part 1: Where Annotations Live — CDS, Metadata Extensions and Local Files
Free sample lesson · open to everyone
Understand the layers of UI annotations: annotations in CDS views, separated into metadata extensions, local annotation files in the app, and how Fiori elements merges them — so you know where to change what.
In this lessonShow sectionsHide sections
Visual overview
The situation: a real project scenario
A developer changed a column label in the CDS metadata extension, but one app still showed the old label. That app had a local annotation overriding the line item. The team documented the rule that layout lives in metadata extensions and removed unnecessary local overrides.
Explanation
This series explains UI annotations, and Part 1 maps where they can actually live: CDS views, metadata extensions, or an app's local annotation file.
In RAP, UI annotations can be written directly in the CDS projection or consumption view. Written there, they're exposed with the OData service, so every app using that service gets them automatically — this is the natural place for semantics shared by all consumers of the service.
Metadata extensions (DDLX files) hold annotations for a view in a separate object instead, as long as the view allows it with @Metadata.allowExtensions: true. This separates UI concerns from the data model and allows layering — for example a core layer and a customer layer — without changing the view itself.
Fiori elements apps can also contain a local annotation file that adds to or overrides annotations for that specific app. This is useful when one app needs a different layout than others using the same service, or when the back end simply can't be changed.
At runtime, these sources merge in a defined order: the app loads the service metadata with its back-end annotations, and then applies the local annotations on top. Later sources override earlier ones for the same target and term. SAP Fiori tools can show the merged result and help navigate back to the actual source of a given annotation.
The rule worth following is to put semantics and defaults shared by all apps in CDS or metadata extensions, and keep app-specific layout in local annotations only when genuinely needed. Mixing annotation sources without a rule like this makes it hard to know why a given field appears the way it does, so documenting the rule within the team helps everyone look in the right place first.
In practice, this means finding a CDS view with @Metadata.allowExtensions and its metadata extension, moving a UI annotation from the view into the extension, overriding one annotation locally in an app, and inspecting the merged annotations in Fiori tools — building toward being able to say, for any visible field, exactly which annotation source controls it.
How the SAP process fits together
SAP PROCESS EXPLORER · Fiori: from service to user
ERPClimb.comCDS Annotations for UI — process breakdown
Topic-specific conceptual flow: how key objects and decisions fit together. SAP configurations and exceptional cases can follow different paths.
Selected process stage
Choose
Annotations live in CDS, metadata extensions or local files
Representative SAP learning flow, not a guarantee of system runtime sequence in every scenario.
Watch out
Common mistakes
No team rule for where annotations belong, so developers add UI annotations wherever is convenient at the time — some directly in the CDS view, some in the metadata extension, some locally in the app. The result is that when a field looks wrong, nobody can say quickly which of three places controls it, and debugging a label or visibility issue turns into a search across multiple files.
Forgetting that a local annotation override exists after the back-end annotation changes. A developer updates a column label in the CDS metadata extension so every app picks it up, but one specific app still shows the old label because it has a local annotation file that overrides that same field — and since the override was added months earlier for an unrelated reason, nobody remembers it's there until the "fix" doesn't show up.
Putting UI-only annotations (labels, importance, criticality) directly in the core CDS data model view instead of a metadata extension. This clutters the view that's meant to define data semantics with presentation concerns, and makes it harder to layer UI changes (e.g., a customer-specific label) without touching the shared view that other consumers depend on.
Missing @Metadata.allowExtensions: true on the CDS view, which silently prevents a metadata extension from being picked up at all — the extension file exists and looks correct, but its annotations are simply never applied, which is confusing because there's no obvious error pointing at the missing flag.
Do this
Best practices
Put annotations shared by every consumer of a service (labels, value lists, criticality, default sort) in CDS or metadata extensions, not in app-local files — this way every app benefits automatically and there's one place to maintain shared semantics.
Prefer metadata extensions over annotating directly in the core CDS view for UI-only concerns. This keeps the data model view focused on data semantics and lets UI annotations be layered (e.g., a core layer plus a customer layer) without editing the shared view itself.
Reserve local annotation files in the app for genuinely app-specific layout needs — a different column order or visibility that only makes sense for one specific app — and keep the list of such overrides short and documented, since every local override is one more place a future change to the back-end annotation won't automatically reach.
Use SAP Fiori tools to inspect the merged annotation result and navigate to the actual source controlling a field, rather than guessing from file names — this turns "why does this field look like this" from a multi-file search into a direct lookup.
In the interview
Interview angle
A practical interview question: "A Fiori elements field shows the wrong label — where do you look, and in what order?" A weak answer only mentions the CDS view's annotations.
A strong answer explains the merge order: back-end annotations (in the CDS view or its metadata extension) are exposed through the OData service first, and then the app's local annotation file, if one exists, is applied on top and overrides anything targeting the same field — so the actual rendered label is whichever source was applied last for that target.
The strong answer also knows to check SAP Fiori tools' merged annotation view to find the winning source quickly, rather than guessing or searching files one by one.
Practice this lesson
Original educational case studies for SAP consultants, not official SAP certification exam questions. Verify product edition and implementation details against the current SAP documentation.
Quick check
0 of 3 questions attempted
Question 1 of 3
What is required on a CDS view to allow metadata extensions?
Question 2 of 3
A label changed in the back end but one app still shows the old label. Why?
Question 3 of 3
Where should annotations shared by all apps using a service live?
Practise this in an interview
Answer in your own words and get instant feedback, the way an interviewer would judge it.
1Explain the different places UI annotations can be defined and how you decide where to put them.
Was this lesson helpful?
Keep exploring
More lessons in this topic
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.