Lesson 3 of 5
Annotations for UI, analytics and semantics
10 min
Listen to this lesson
Annotations are metadata that start with @ and sit in front of a view, a field or an association. They do not change which rows the view returns. They tell frameworks and consumers what the data means and how to use it: that a field is an amount, that the view is an analytical cube, that a column should appear in a Fiori table. Learn the families and you can read almost any SAP view.
The header annotations in ADT’s template
SAP's ABAP Data Models guide explains the annotations in ADT's standard view entity template, and the defaults are deliberate. @AccessControl.authorizationCheck defaults to #NOT_REQUIRED, which makes access control optional. @EndUserText.label takes the description you enter. @Metadata.ignorePropagatedAnnotations: true switches off inherited annotations so higher-layer views stay stable when lower layers change; SAP warns that this can drop mandatory annotations such as currency references, which you must then set again. @AbapCatalog.viewEnhancementCategory defaults to #NONE, so the view cannot be extended unless you allow it. The @ObjectModel.usageType annotations (service quality, size category, data class) tell consumers how expensive the view is to call.
| Annotation (template default) | What it controls | What to check in review |
|---|---|---|
| @AccessControl.authorizationCheck (#NOT_REQUIRED) | Whether CDS access control is mandatory, optional or not allowed | Business data views should normally be protected |
| @Metadata.ignorePropagatedAnnotations (true) | Whether annotations from lower views are inherited | Currency and unit references are still present |
| @AbapCatalog.viewEnhancementCategory (#NONE) | Whether the view can be extended | Set deliberately if partners or key users must extend |
| @ObjectModel.usageType.sizeCategory (#S) | Expected data volume | Matches reality: core return items are not small at year-end |
Header annotations from ADT’s template, as SAP documents them, with review prompts.
Semantics and UI
Semantic annotations make fields behave correctly everywhere. Contoso's TotalDeposit is annotated with @Semantics.amount.currencyCode: 'Currency', so every consumer formats it with the right decimals for USD or MXN. A text association plus @ObjectModel.text.element lets a UI show "Great Lakes Fleet Services" next to the customer number. UI annotations such as @UI.lineItem and @UI.selectionField tell a Fiori elements app which columns and filters to show. SAP's RAP guide recommends putting UI annotations in a metadata extension, a separate object with the same name as the view, so the data model stays clean; the view needs @Metadata.allowExtensions: true for that.
- Basic viewSemantic annotations: amounts, units, texts
- Consumption viewZC_CMC_OpenCoreDeposits with @Metadata.allowExtensions: true
- Metadata extension@UI.lineItem for Agreement, Customer, TotalDeposit, ValidTo; @UI.selectionField for Customer
- ServiceThe view is exposed through a service definition and binding
- Fiori elements listColumns and filters appear without UI code
Two more families save a lot of UI work. @Consumption.valueHelpDefinition attaches a value help to a field, for example a customer search on the agreement's Customer field that reads a released customer view, so users pick valid values instead of typing numbers. @Search.searchable with fuzzy search settings on chosen fields gives the list a free-text search box. Both are cheap to add and easy to test: the value help offers only valid customers, and searching "Great Lakes" finds Great Lakes Fleet Services.
Analytics
For analytical apps, a view declares its role. @Analytics.dataCategory: #CUBE marks a fact view with measures, #DIMENSION marks master data such as customers, and @Aggregation.default: #SUM tells the analytical engine how to total a measure. Contoso's finance process owner Dan wants open deposits by customer and month; a small cube over the item view, with the customer as a dimension, gives him that without a custom report. Analytical queries built on cubes are covered in SAP's ABAP Analytics guide.
What would you do?
After Kenji's team sets @Metadata.ignorePropagatedAnnotations to true on the consumption view, activation fails with an error about the TotalDeposit field. What is the most likely cause?
- Annotations add meaning; they do not change which rows a view returns.
- ADT’s template sets authorizationCheck #NOT_REQUIRED, ignorePropagatedAnnotations true and viewEnhancementCategory #NONE.
- Amounts and quantities need currency and unit references through @Semantics annotations.
- Put UI annotations in metadata extensions; allow them with @Metadata.allowExtensions: true.
- @Analytics.dataCategory marks cubes and dimensions for analytical apps.
Check your understanding · not graded
Lesson check
1. What is the default value of @AccessControl.authorizationCheck in ADT’s view entity template?
2. Where does SAP recommend placing UI annotations such as @UI.lineItem?
3. Which annotation marks a view as an analytical fact view with measures?
4. Why might activation fail after setting @Metadata.ignorePropagatedAnnotations to true?