Skip to Content
Technical Articles
Author's profile photo Tapodipta Khan

CDS Exposing to Odata – New And Experienced professionals- 6

Premise-

There are many SAP blogs out there that explains inner working of CDS views or core data services in SAP’s S/4 boxes. But there are still struggle among experienced professionals who is switching from ECC system to S/4.

This blog is dedicated towards experienced professionals working on ECC systems for many years and yet to jump to S/4.In the next few min, we will look at a very basic concept of a CDS view and try to evaluate inner working of the CDS using classic SAP tools.

 

Pre-Requisites –

You have read / understood / Prototype items on Previous blogs.

SAP CDS for New And Experienced professionals | SAP Blogs

Consuming CDS for – New And Experienced professionals- 2 | SAP Blogs

CDS Annotations for – New And Experienced professionals- 3 | SAP Blogs

CDS in Real life requirements – New And Experienced professionals- 4 | SAP Blogs

CDS Architecture – New And Experienced professionals- 5 | SAP Blogs

 

Recap-

We started this journey with creating a simple CDS for a custom table in the first blog.

In the second blog we looked at simple way to consume CDS views in ABAP executables.

Took a deep dive into annotations in third blog.

Finally looked at an approach to extend CDS views.

All concluded on CDS Architecture.

 

Target-

Current blog will be a overlap between CDS and ODATA topics. We have already looked at option to consume CDS in any ABAP executables, this blog will explain how to expose CDS as a service using ODATA.

 

 

Lets Start –

In First blog we created a data dictionary table named ZTRAVEL and a CDS view ZCDS_TRAVEL.

In this blog we will try to create a ODATA service to expose the CDS view.

 

Step1: Create a new sub package ZTRAVEL_BOOKING_ODATA in main ZTRAVEL_BOOKING package. Go to transaction SEGW- (SAP Gateway Service Builder). Click on the new ICON.

Step2: Create a new ODATA project named – ZODATA_ZCDS_TRAVEL ( ODATA Project for CDS Service ZCDS_TRAVEL). Enter the package ZTRAVEL_BOOKING_ODATA click on OK.

This will create an Empty service.

 

Step3: Lets enter a data model by right clicking the data model and click on import-> DDIC Structure.

 

Step4: We will import the SQL view in this case ZVSQL_TRAVEL with the entity as CdsTravel.

Step5: You can choose the fields that you would like to expose as part of this ODATA – In this case choose everything except client / Mandt.

Select Employee No as key click on finish.

This actions will create Entity sets and Service Implementation will be visible.

 

Step6:  Right Click on Service implementation CdsTravelSet and click on MAP to Data Source.

 

Step7: Find the CDS view via SADL model as shown below and click ok.

 

Step 8: Click on Generate Run time object button from toolbar. This will generate the below items automatically click on Ok. Do no worry about what they are I will explain in the up coming blog in details. Save the service.

 

Step9: Go to transaction /IWFND/MAINT_SERVICE in a new window. Click on Add service – Search technical service Z*CDS* you will find the service we just created in Step 8. Once you find it select the service and click on Get service.

Step10: click ok.

Step11: If you have completed successfully the following message should appear.

 

Conclusion:

In exact 11 steps we were able expose CDS service as a ODATA. Congratulations, Keep learning.

 

 

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jun Wu
      Jun Wu

      mapping to cds is not the preferred way of implementing odata, I think. unless your system very old.

      go with RDS

      Author's profile photo Tapodipta Khan
      Tapodipta Khan
      Blog Post Author

      Agreed RDS is definitely a better approach. You are correct to say not every S/4 version has the same capability also it's very unfortunate that most of the Standard CDS is not supplied with RDS.

      Author's profile photo Jun Wu
      Jun Wu

      Supplied with rds?

      what’s your rds?

       

      Author's profile photo Tapodipta Khan
      Tapodipta Khan
      Blog Post Author

      what’s your rds? - Didnt get you?

      Author's profile photo Jun Wu
      Jun Wu

      What is the rds you are talking about?

      Author's profile photo Tapodipta Khan
      Tapodipta Khan
      Blog Post Author

      I think we are both talking about - Referenced Data Source as RDS.

      Creating an OData Service based on a Referenced Data Source (RDS) - SAP Help Portal

      The targeted audience for these blogs are to get started and have a basic understanding of CDS, ODATA services.

      As RDS by default require pre-requisites and understanding of the below - It will be difficult to for many who is just starting out.

      You require advanced knowledge of the SAP Gateway Service Builder and OData.

      Your require basic knowledge of the Enterprise Procurement Model (EPM).

       

      Please keep watching this space. I will set up some new blogs with advanced topics such as advanced CDS and ODATA.

       

      Author's profile photo Jun Wu
      Jun Wu

      why you are saying cds supplied with rds? i don't think rds need any prerequisite knowledge...

      for developer, one using mapping, one using reference

      Author's profile photo Kevin Hu
      Kevin Hu

      I think RDS based odata is still ok considering system 1809 was used for this blog post series, although not indicated in this blog specifically. And I think you are right, odata auto exposure should be already available in 1809 and recommended over RDS, although many standard fiori apps are still written in RDS in this modern age. 🙂