Subject: SAP-HANA-Live | SAP Domain
In the modern SAP landscape, enabling seamless integration between backend data and user-facing applications is critical. OData services play a key role in this integration by exposing SAP data models over HTTP in a standardized way. With the advent of Core Data Services (CDS) Views on SAP HANA Live, generating OData services directly from CDS Views has become an efficient and powerful approach to expose live, real-time data for consumption by SAP Fiori apps, SAP Analytics Cloud, or other external clients.
This article explores how to generate OData services from CDS Views, the benefits of this approach, and the key steps involved.
OData (Open Data Protocol) is a REST-based protocol that enables querying and manipulating data via standardized web services. SAP leverages OData extensively to provide a unified API framework for accessing SAP backend data in a scalable, secure manner.
Traditional methods of creating OData services often involved manual service implementation in SAP Gateway. CDS Views simplify and accelerate this process with the following advantages:
Create a CDS View with the required data fields and business logic. Make sure to include proper annotations to enhance the OData service.
Example of a simple CDS View with OData annotations:
@AbapCatalog.sqlViewName: 'ZCDS_SALESORDER'
@OData.publish: true
@EndUserText.label: 'Sales Order OData CDS View'
define view ZCDS_SalesOrder as select from vbak {
key vbeln, -- Sales document number
erdat, -- Creation date
kunnr, -- Customer number
netwr -- Net value
}
@OData.publish: true instructs the system to generate and publish an OData service automatically for this view.After defining the CDS View in the ABAP Development Tools (ADT), activate it to generate the underlying SQL view and register the OData service metadata.
Navigate to the SAP Gateway Service Builder (transaction /IWFND/MAINT_SERVICE) and register the generated OData service.
ZCDS_SALESORDER_CDS).Use tools like SAP Gateway Client (transaction /IWFND/GW_CLIENT) or external REST clients (Postman, browsers) to test the service endpoint.
Example URL format:
https://<SAP_system_host>/sap/opu/odata/sap/ZCDS_SALESORDER_CDS/
You can query entity sets and apply OData query options like $filter, $select, or $orderby.
CDS Views support various annotations to improve the generated OData services:
Annotations enable seamless integration with SAP Fiori Elements and other OData consumers, offering rich UI capabilities without extra coding.
Generating OData services directly from CDS Views is a best practice in the SAP HANA Live environment to unlock real-time data for modern applications. This approach significantly reduces development effort while ensuring data consistency and performance. By leveraging CDS annotations and SAP Gateway capabilities, organizations can build scalable, maintainable, and secure OData APIs that power SAP Fiori apps, analytics platforms, and external integrations.