In the modern SAP ecosystem, OData (Open Data Protocol) has become a fundamental technology for exposing and consuming data through RESTful APIs. Within SAP HANA Live and SAP S/4HANA environments, OData services provide a standardized way to interact with real-time data models, particularly those defined using Core Data Services (CDS) views.
This article focuses on working with OData queries, highlighting how they integrate with SAP HANA Live data models, their structure, and practical tips for efficient use in SAP applications.
OData is a protocol built on web standards (HTTP, REST, and JSON/XML) that allows clients to query and manipulate data from SAP backend systems in a uniform way. In SAP HANA Live, OData services typically expose data from CDS views, enabling frontend apps—especially SAP Fiori applications—to consume live transactional and analytical data efficiently.
SAP CDS Views can be annotated to automatically generate OData services without additional programming. These annotations define how data fields are exposed, filtered, sorted, and navigated.
For example, a CDS view annotated with:
@OData.publish: true
define view Z_CDS_SalesOrder as select from sales_order {
key sales_order_id,
order_date,
customer_name,
total_amount
}
This triggers SAP Gateway to expose this CDS view as an OData service accessible via URL endpoints.
An OData query uses standard HTTP methods, primarily GET, to retrieve data. Queries can be refined using system query options:
GET /sap/opu/odata/sap/Z_SALESORDER_SRV/SalesOrderSet?$filter=total_amount gt 1000&$select=sales_order_id,customer_name&$top=10
This query requests the first 10 sales orders with a total amount greater than 1000, returning only the sales order ID and customer name.
Associations in CDS views map to navigation properties in OData services. Using $expand, you can retrieve related data in a single request.
GET /sap/opu/odata/sap/Z_SALESORDER_SRV/SalesOrderSet?$expand=Customer
This query fetches sales orders along with their associated customer details.
$filter to minimize transferred data and improve performance.$top and $skip to implement pagination.SAP provides several tools to analyze and debug OData queries:
Working with OData queries in SAP HANA Live unlocks powerful real-time data access capabilities for SAP applications, especially in combination with CDS views. Mastering OData syntax and best practices enables developers and analysts to efficiently retrieve, filter, and consume enterprise data, facilitating agile and responsive SAP Fiori apps and analytics.
As SAP continues to emphasize cloud and API-first architectures, OData remains a critical skill in the SAP professional's toolkit.