CDS Section 3: Using annotation, expose CDS views as an OData service

Expose CDS View as an OData Service

CDS Section 3: Using annotation, expose CDS views as an OData service , You are probably already familiar with CDS Views if you have been following our series on SAP ABAP on HANA. If not, kindly refer to our HANA ABAP Parts IV and V, where we covered a thorough analysis of CDS Views and the introduction of Core Data Services, respectively. Additionally, you are aware that SEGW is the t-code for generating OData Projects and ultimately publishing an OData Service if you have been using our SAP Netweaver Gateway and OData Services Tutorial Course.

However, would it surprise you if we told you that you could establish your OData projects without utilizing a SEGW transaction?Today, we’ll demonstrate how to expose CDS View as an OData service using only a few annotations (i.e., SQL code).

Overview


We have thoroughly investigated the CDS perspectives with key features.Another wonderful power that CDS offers users is the ability to expose views as OData services. Importing the view you built is a traditional method of creating a service in SEGW.

This article shows how to reveal a view as a gateway service using only a subtle annotation.There’s no need to use SEGW to construct services.Sounds fantastic?See if we can make that happen.

Technical Context
We have been using Eclipse Luna for CDS views.
The gateway application has been implemented with OData version 2.

Step I: Construct a view that joins tables VBAP and MARA on the left. We have classified MARA as “prod” and VBAP as “soitem.” An outside connect on the left between

CDS View without SEGW

Fig. 1-Make the Initial View

Step II: Work with the Association to create a second view.Associations in Gateways are more similar to those in CDS perspectives. To associate or conceptually join one data source to a target data source subject to a specified condition, you build an association. In theory, associations connect two entities if data sources are thought of as OData service entities.

Association and OData Annotation


Fig. 2: Establish a view using OData annotation and association

Pay close attention to the annotation on the sixth line:True, @OData.publish.This is the article’s magic spell for today.

Step III: Our view is now prepared. We should be able to view data from the Header table (VBAK), Item table (VBAP), and Product table (MARA) using the DDL view.

DDLS view

Fig.3- DDLS

Data from the view

Data from the view in Fig. 3

Fig. 4: View of OData Exposure

Step V: To register the service generated by CDS, proceed as directed to transaction /IWFND/MAINT_SERVICE in the gateway system.

OData Exposure in View

Fig.4- OData Exposure in View

Step – V :

Find Service in /IWFND/MAINT_SERIVCE

Fig.5- Find Service in /IWFND/MAINT_SERIVCE

Step – VI :
When the service is located, select it to register and store it in the relevant package.Take note that we haven’t created any services using SEGW.The OData Annotation maintained allowed this service to be generated automatically.

Register Service

Step VII:

Use the appropriate OData query to test your service now using the /IWFND/GW_CLIENT transaction. Note that in contrast to a typical gateway, the query uses “to_{association name>” to travel to the second data set. Since vbeln was added as an association condition to our “ZTEST_ASSOC_VIEW2,” an OData query must be used to retrieve the value in order to retrieve the data.

Test Gateway Data Fetch

Fig.7: Data Fetch for Test Gateway

Restrictions
Additionally, please be aware that this service can only do GET operations.With this CDS view OData Exposure, no other CRUD actions are possible.

This technique of exposing CDS views as OData services is quite useful, even with the aforementioned limitation, since CDS views are often developed for data fetching (GET operations). This further demonstrates the strength of the Core Data Services’ annotations (New SQL).

you may be interested in this blog here:-

What is ERP?

Get Latitude and Longitude of any place using Google Map API in SAP

5 Methods for Using Your Salesforce Email Sender Reputation: An Story of Redemption

Related Posts

SAP Netweaver Gateway and SAP OData. Section IV. OData Service Association and Navigation

As of our third tutorial in the series on SAP Netweaver Gateway and OData, our data models are built to independently retrieve item data from EKPO and header data from…

SAP Netweaver Gateway and OData. Section VI. Commonly Asked Questions

The SAP Netweaver Gateway and OData Tutorials’ five earlier sections included practical exercises along with some technical insights.Those lessons would be helpful and sufficient for ABAPers, but in order to…

Leave a Reply

Your email address will not be published. Required fields are marked *

You Missed

ABAP Programming Model for SAP Fiori – 11 – Enabling Draft Functionality for Transactional Apps

  • By Varad
  • September 17, 2024
  • 2 views
ABAP Programming Model for SAP Fiori – 11 – Enabling Draft Functionality for Transactional Apps

Just 4 Versions of the same program to understand OOPs ABAP

  • By Varad
  • September 16, 2024
  • 5 views

SAP Netweaver Gateway and OData SAP. Section I: A Brief History

  • By Varad
  • September 16, 2024
  • 3 views
SAP Netweaver Gateway and OData SAP. Section I: A Brief History

SAP Netweaver Gateway and OData. Section Two. Make your initial ODataService.

  • By Varad
  • September 14, 2024
  • 3 views

SAP Netweaver Gateway and SAP OData. Section 3. Options for Queries in OData Service URL

  • By Varad
  • September 13, 2024
  • 4 views

SAP Netweaver Gateway and SAP OData. Section IV. OData Service Association and Navigation

  • By Varad
  • September 12, 2024
  • 6 views