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 XI/PI – Invoice Attachment Transfer from ARIBA to VIM

The documents that are connected to the invoice in the Ariba Network system should be transferred to the VIM system via PI Integration as part of the Ariba Supplier Invoice…

Attachments for SAP XI/PI – ARIBA Invoices sent via PI to S/4HANA

Integration with SAP systems has never been more intriguing, especially with Ariba, Workday, Concur, Successfactors, Fieldglass, Hybris, and other satellite cloud solution vendors banging on doors every day. 🙂 I…

Leave a Reply

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

You Missed

SAP XI/PI – Invoice Attachment Transfer from ARIBA to VIM

  • By Varad
  • November 8, 2024
  • 2 views
SAP XI/PI – Invoice Attachment Transfer from ARIBA to VIM

11 Steps to Include a New Field in an Already-Existing SAP LSMW Batch Input Recording

  • By Varad
  • November 6, 2024
  • 2 views

Part 23 of ABAP for SAP HANA. How Can AMDP Be Used to Access Database Schema Dynamically?

  • By Varad
  • November 4, 2024
  • 2 views

S/4HANA VDM 1 Employing CDS Virtual Data Model for Embedded Analytics

  • By Varad
  • November 1, 2024
  • 5 views