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

Important T codes for FI GL AR AP

  • By Varad
  • December 21, 2024
  • 19 views
Important T codes for FI GL AR AP

Dynamically Download Data From Any SAP Table in ABAP-740 – Part 1

  • By Varad
  • December 20, 2024
  • 13 views
Dynamically Download Data From Any SAP Table in ABAP-740 – Part 1

Error While Setting Up Trusted System RFC

  • By Varad
  • December 19, 2024
  • 11 views
Error While Setting Up Trusted System RFC

 Credit Management T codes in SAP

  • By Varad
  • December 18, 2024
  • 24 views
 Credit Management T codes in SAP

Troubleshooting SAP BD22: Delete Change Pointer Not Picking Correct Processed Messages

  • By Varad
  • December 17, 2024
  • 56 views
Troubleshooting SAP BD22: Delete Change Pointer Not Picking Correct Processed Messages

Working with Shell Scripts in SAP ABAP Environment

  • By Varad
  • December 16, 2024
  • 34 views
Working with Shell Scripts in SAP ABAP Environment