← Back to list

Creating a CDS View and Exposing It as an OData Service in SAP

SAP Core Data Services (CDS) views provide a powerful way to define and consume data in SAP systems. One common use case for CDS views is…

Ruchi Kumari · 2025-01-06 07:57 · 0 claps · 3.3 min read paywalled
#cds-view #odata #fiori #ui5 #sap-hana
Open on Medium ↗
Wiki topics: CRY · Crypto & Web3

Creating a CDS View and Exposing It as an OData Service in SAP

SAP Core Data Services (CDS) views provide a powerful way to define and consume data in SAP systems. One common use case for CDS views is exposing them as OData services for use in web and mobile applications. This blog will guide you through the process of creating a CDS view and exposing it as an OData service.

Some key Concepts

Before diving into the implementation, it’s important to understand the key concepts:

  • CDS View: A CDS view is a data abstraction layer in SAP that allows you to define the structure and logic of your data retrieval.
  • OData Service: OData (Open Data Protocol) is a standardized protocol for building and consuming RESTful APIs.

Creating the CDS View

  1. Open ABAP Development Tools (ADT): Launch Eclipse and connect to your SAP system.
  2. Create a New CDS View:
  • Right-click on your package and select New > Other > Core Data Services > Data Definition.
  • Provide a name for the CDS view (e.g. Z_SALES_DATA) and a description.

3. Define the Data Model: Use the CDS syntax to define your view. For example:

Activate the CDS View: Save and activate the CDS view to make it available in the system.

Enabling the CDS View for OData

  1. Annotate the CDS View: Add annotations to make the CDS view OData-ready. For example:
  • @OData.publish: true

  1. This automatically generates an OData service.
  2. Activate the CDS View Again: Save and activate the view to trigger the OData service generation.

Registering the OData Service

  1. Access the Service Catalog: Log in to the SAP GUI and navigate to the transaction /IWFND/MAINT_SERVICE.
  2. Add the Service:
  • Click on Add Service.
  • In the System Alias field, enter your system alias.
  • Search for the service (e.g., Z_SALES_DATA_CDS) and add it.

3. Assign a Technical Service Name:

  • Choose a technical name for the service.
  • Save your changes.

After successfully creation of the service , you will get this information message.

Testing the OData Service

  • Transaction Code: /IWFND/MAINT_SERVICE
  • This will take you to the “Maintain Services” screen, where you can manage your OData services.
  • In the “Maintain Services” screen, find the service by searching for its name or technical name in the “Service” field.
  • If the service is already added, it should appear in the list. If not, you’ll need to register the service by clicking on the “Add Service” button and then entering the system alias and other relevant details.
  • Go to the SAP gateway client .

Choose the entity set (e.g., Z_SALES_DATA) to fetch data.

  • Select the appropriate HTTP method (usually GET for testing a service response).
  • Execute.
  • After executing the request in the Gateway Client, review the response that appears.

Successful Response:

  • If the service is working correctly, you should receive a HTTP 200 OK status code, indicating a successful request.
  • The response will typically include the requested data in JSON or XML format (depending on the service configuration).

Best Practices

  • Use meaningful names and descriptions for CDS views and OData services.
  • Implement access control using annotations like @AccessControl.authorizationCheck.
  • Test thoroughly in a development environment before moving to production.

Conclusion

By following the steps outlined above, you can efficiently create a CDS view and expose it as an OData service in SAP. This approach simplifies data access and enables seamless integration with various applications, enhancing the value of your SAP system.


메타데이터
post_id
38720c87f98b
slug
creating-a-cds-view-and-exposing-it-as-an-odata-service-in-sap-38720c87f98b
url
https://medium.com/@ruchirani88099/creating-a-cds-view-and-exposing-it-as-an-odata-service-in-sap-38720c87f98b
canonical_url
https://medium.com/@ruchirani88099/creating-a-cds-view-and-exposing-it-as-an-odata-service-in-sap-38720c87f98b
author_url
https://medium.com/@ruchirani88099
status
ok
fetched_at
2026-06-26 21:52:29