CDS Views
Architect / Cross-trackIntermediate

CDS Annotations for UI, Semantics and Analytics

Understand how annotations add meaning for UI, analytics, search and behavior.

Explanation

Annotations make CDS powerful. They describe labels, semantics, UI behavior, analytics, search, value help and OData exposure. For example, @EndUserText.label gives business-readable labels, @Semantics.amount.currencyCode links amount to currency, and UI annotations help Fiori elements render list reports and object pages. Analytical annotations can make CDS query-ready. Annotations should be used intentionally. Too many annotations in the wrong layer make the model hard to maintain. Keep generic semantic annotations in reusable layers and UI-specific annotations in consumption views.

Code example

ABAP Code
@EndUserText.label: 'Customer Revenue Consumption'@UI.headerInfo: { typeName: 'Customer Revenue', typeNamePlural: 'Customer Revenues' }define view entity ZC_CustomerRevenue as select from ZI_CustomerRevenue{ @UI.lineItem: [{ position: 10 }] key Customer,  @UI.lineItem: [{ position: 20 }] CustomerName,  @Semantics.amount.currencyCode: 'Currency' @UI.lineItem: [{ position: 30 }] TotalRevenue,  Currency} // Purpose:// UI annotations help Fiori elements render fields.// Semantics annotation tells which currency belongs to amount.

Real project scenario

A Fiori list report was created without custom frontend coding because the CDS consumption view provided UI line-item annotations, selection fields and semantic amount/currency annotations.

Common mistakes

- Adding UI annotations to every low-level view. - Not linking amount with currency. - Using technical labels in UI. - Adding annotations without understanding consumer.

Best practices

- Use semantic annotations for amount, quantity, date and currency. - Keep UI annotations in consumption layer. - Use business-friendly labels. - Test generated Fiori UI behavior.

Interview angle

A practical answer should mention annotations for labels, UI, analytics, semantics and Fiori elements.