CDS Exposing to Odata – New And Experienced professionals- 6
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.
You have read / understood / Prototype items on Previous blogs.
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.
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.
In exact 11 steps we were able expose CDS service as a ODATA. Congratulations, Keep learning.