SAP Fiori Elements enables rapid development of SAP Fiori applications based on standardized templates and metadata-driven UIs, reducing the need for extensive UI coding. A key enabler of this powerful framework is the use of Core Data Services (CDS) views—semantically rich data models defined in the ABAP layer. Custom CDS views allow developers to tailor business data models to specific requirements and expose them efficiently to Fiori Elements applications.
This article explores how to create and use custom CDS views to build flexible, performant, and scalable Fiori Elements apps that fit unique business needs.
Core Data Services (CDS) is SAP’s advanced data modeling infrastructure integrated into the ABAP layer. CDS views provide:
While SAP provides many standard CDS views for common scenarios, business requirements often call for tailored data models:
Custom CDS views ensure your Fiori Elements apps present exactly the data users need in an optimized way.
Create a new CDS view in ABAP Development Tools (ADT) within Eclipse or SAP Business Application Studio:
@AbapCatalog.sqlViewName annotation to specify the database view name.@Analytics.dataCategory if the view supports analytical scenarios.Example snippet:
@AbapCatalog.sqlViewName: 'ZCDS_SALESORDER'
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Custom Sales Order CDS View'
define view Z_CDS_SalesOrder as select from sales_order_header as soh
inner join sales_order_item as soi on soh.order_id = soi.order_id
{
key soh.order_id,
soh.customer_id,
soi.product_id,
soi.quantity,
soi.net_price
}
Add UI and semantic annotations to control how the data appears in the Fiori Elements app:
@UI.lineItem to define fields displayed in list reports.@UI.selectionField to mark filterable fields.@ObjectModel annotations for entity behavior.@Consumption.valueHelpDefinition for value helps.Example annotations:
@UI.lineItem: [{ position: 10, label: 'Order ID' }, { position: 20, label: 'Customer' }]
@UI.selectionField: [{ position: 10 }]
@UI.identification: [{ position: 10 }]
define view Z_CDS_SalesOrder ...
To consume the CDS view in a Fiori Elements app, expose it via an OData service:
@OData.publish: true) on top of the CDS view to generate OData metadata automatically.Example:
@OData.publish: true
define service Z_SalesOrderService {
expose Z_CDS_SalesOrder;
}
/IWFND/MAINT_SERVICE.@AccessControl.authorizationCheck) to protect data.Custom CDS views form the backbone of scalable, maintainable, and user-friendly SAP Fiori Elements applications. By defining rich semantic data models with precise annotations and exposing them as OData services, developers can leverage the best of SAP’s UI framework and database technology. This approach accelerates app development, improves performance, and ensures that end-users receive tailored, context-aware interfaces that drive business efficiency.