Share on social networks!

Publish CDS views to SAP

With the concept of publishing CDS views as an OData service, a new and simple way to create OData services has been introduced.

With this approach, the OData model definition and OData service runtime are provided generically, according to SADL (Service Adaptation Description Language).

9ae90a80 a1bc 4aff b8e8 1083ccb236ef
The requirement for this is that the annotation @OData.publish: true is specified at the view level.

To illustrate the step by step, let's go back to the example presented in the previous entry. “Creating CDS Viewsfrom Eclipse.

CDS Views
CDS Views

Publish CDS Views as OData

In Eclipse, we add the necessary annotation for publishing; @OData.publish: true.

image 30

The next step will be to activate the view by pressing the “match”;

image 21

The ADT development tools delegate the activation request to the SADL framework, which generates various SAP Gateway artifacts that are stored in the backend of the AS ABAP application server and are required for the activation of the OData service in the SAP Gateway Hub system.

Once the activation has been carried out correctly, we should see a message “warning" like the one in the image, which tells us that we must move on to the second part of the process, where we will activate the service from SAP Gateway in the SAP backend.

As we can see, the service to be activated is; ZB_CDS_BASIC_ORDERS_CDS

image 29

With this, we enable the OData service in SAP Gateway, so we have a relationship between the technical name of the OData service and the corresponding back-end service.

Activate the Service in SAP Gateway

We access the transaction /n/iwfnd/maint_service

image 25

The first step is to recover our service so that we can activate it in the backend.

To do this, on the transaction selection screen, click on “Add Service”.

image 24

This takes us to the search engine where we will indicate the name ZB_CDS_BASIC_ORDERS_CDS and we will click on “Get Services” so that the system can recover it.

image 28

Once we can view it, we'll select it and click "Add Selected Services" so that it's included in the list of available services in our backend.

image 26

We assign the desired package and click continue.

image 19

If everything went as expected, we will receive the following message.

image 28

We return to the transaction /n/iwfnd/maint_service, where we should have the OData service already available.

We will conduct a search to locate you quickly.

image 31

Once located in the list, click on the name to check its correct activation.

image 32

The service can be tested in a browser or from the SAP Gateway client.

To get the URL of the published service and test it directly from the browser, we return to the CDS view and hover the mouse over the annotation icon @OData.publisher: true where the system displays an information window that allows you to navigate directly to the URL by clicking on the OData-Service text.

We see how in Eclipse the icon has changed, and we can navigate to the URL from here.

image 27
image 23

We can also test the call from the SAP Gateway client itself.

Since the transaction /n/iwfnd/maint_service we select the service and press “SAP Gateway Client”.

image 20

With this we recover the URL and we can launch the call by clicking on “Execute”.

image 33

Conclusion

Publishing CDS views as an OData service offers an efficient and structured way to expose data from the SAP backend to external environments. Thanks to annotation @OData.publish: true and support for the SADL framework, the process is considerably simplified, integrating development in Eclipse with activation in SAP Gateway.

This approach not only streamlines service creation but also ensures better traceability and reusability of the data model for the direct benefit of the relevant company or institution, enabling developers to build more robust, consistent, optimized, and tailored interfaces within the SAP ecosystem.

Leave a comment

EIP International Business School informs you that the data in this form will be processed by Mainjobs Internacional Educativa y Tecnológica, SAU as the party responsible for this website. The purpose of collecting and processing personal data is to manage your subscription to the newsletter as well as to send commercial information about the services of the data controller. The legitimacy is the explicit consent of the interested party. Data will not be transferred to third parties, except under legal obligation. You may exercise your rights of access, rectification, limitation and deletion of data at compliance@grupomainjobs.com, as well as the right to lodge a complaint with the supervisory authority. You can consult additional and detailed information on Data Protection in the Privacy Policy that you will find on our website.