Subject: SAP-Fiori-Elements
Field: SAP
In the world of SAP Fiori Elements, Core Data Services (CDS) views serve as the backbone for data modeling. While CDS views define the structure and content of data, annotations enrich these views with metadata that drive the behavior, layout, and interaction of SAP Fiori applications — without writing a single line of UI code.
This article explores how to use data annotations effectively in CDS views to develop powerful, UI-ready applications with SAP Fiori Elements.
CDS annotations are metadata tags used to provide additional semantics to CDS entities. These annotations:
Annotations can be grouped broadly into:
@UI.lineItem, @UI.fieldGroup)@ObjectModel.readOnly)@Search.defaultSearchElement)@OData.publish: true)Annotations allow you to design rich user interfaces without deep front-end development. SAP Fiori Elements interprets these annotations and renders fully functional UIs based on them. This reduces:
By centralizing metadata in the backend, annotations promote model-driven development.
Here are some of the most important CDS annotations and their use in Fiori Elements applications:
@OData.publish: trueUsed to automatically expose the CDS view as an OData service.
@AbapCatalog.sqlViewName: 'ZMY_SALES_VW'
@OData.publish: true
define view ZMY_SALES as select from vbak {
key vbeln,
erdat,
netwr
}
@UI.lineItemDefines fields that appear in a list report or table.
@UI.lineItem: [{ position: 10 }]
vbeln as SalesOrder,
@UI.lineItem: [{ position: 20 }]
erdat as CreatedOn
@UI.identificationUsed to display fields in an object page header.
@UI.identification: [{ position: 10 }]
vbeln as SalesOrder
@UI.selectionFieldMarks a field as a filter field in the List Report app.
@UI.selectionField: [{ position: 10 }]
erdat as CreatedOn
@Search.defaultSearchElementDefines fields used in the smart search bar.
@Search.defaultSearchElement: true
vbeln as SalesOrder
@ObjectModel.readOnlySets the CDS entity as read-only in the UI.
@ObjectModel.readOnly: true
@AbapCatalog.sqlViewName: 'ZSO_DEMO_VW'
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales Order Demo View'
@OData.publish: true
define view ZSO_Demo as select from vbak
association [0..*] to vbap as _Items on $projection.vbeln = _Items.vbeln
{
@UI.lineItem: [{ position: 10 }]
@UI.selectionField: [{ position: 10 }]
key vbak.vbeln as SalesOrder,
@UI.lineItem: [{ position: 20 }]
@UI.selectionField: [{ position: 20 }]
vbak.erdat as CreatedDate,
@UI.lineItem: [{ position: 30 }]
vbak.netwr as NetValue,
_Items
}
When activated and exposed via OData, this view can be consumed directly by a List Report Fiori Elements application — with automatic table rendering, filters, and navigation to item details.
position consistently to control the order of fields in the UI.@UI.fieldGroup to improve clarity.Annotations in CDS views are the linchpin of model-driven development in SAP Fiori Elements. They allow developers to define how data should be presented and interacted with — all from the backend. Mastering them not only accelerates development but ensures a consistent and maintainable UI aligned with SAP’s UX strategy.
By combining CDS views with annotations, SAP teams can unlock the full potential of Fiori Elements, delivering agile, scalable, and user-centric applications with minimal coding.