How to create External API using custom CDS view on S/4 Hana Cloud
Introduction: This document describes that if the standard API is not available to fulfil any integration requirement, then how to create an external API using standard or custom CDS view in S/4HANA cloud so that we can get the required data via created external API
Here I will take one example where i want to fetch the address details of a supplier, the standard CDS view of supplier does not provide the address details of the supplier, it only provides the AddressID of the supplier and another CDS view can provide the address details using that AddressID as a filter in join condition.
For creating external API from custom CDS view, Let’s create custom CDS view and then create a custom communication scenario.
Consider a scenario where we need supplier address via custom CDS view.
**Standard API is available to full fill this requirement but here I am taking this example for explaining purpose.
So, let’s start.
Login to S/4 Hana public cloud and go to Extensibility->Custom CDS View(Figure 1)
Now, give any label, name would be created automatically.
Now here we need to add data source, data source can be standard or custom.
First let’s add primary data source.
Now add associated data source, lets add I_Address_2 here to get address details of Supplier based on AddressID field in primary data source.
After adding data sources, next step is to add parameters, but we can’t add parameters when Scenario is “External API”.
After adding elements, just click on publish and wait until status changes to “Publishing Successful”.(Figure 9)
Go to Extensibility-> Custom Communication Scenarios(Figure 11)
Publish it (Figure 16)
Conclusion: After reading this blog, you have learnt that how to create an external API from the CDS view and publish it for external systems to access it
Dear Dharam Verma,
I hope this message finds you well. I recently came across your informative blog, and I want to express my gratitude for sharing your knowledge with us. It has been truly insightful.
I do have a few queries regarding the topic discussed in your blog. I would greatly appreciate your guidance in clarifying them for me.
Firstly, I would like to know if the same External API you created can be used for posting data into SAP S/4 Hana Cloud from third-party apps or systems? From my understanding, you selected "Inbound Service" in the Custom Communication scenario. However, shouldn't it be outbound, considering that the data was pulled from SAP S/4 Hana Cloud?
I kindly request your assistance in providing clarification for these queries. Your expertise and insights would be of immense help to me.
Thank you for your time and consideration.
No external APIs can not be used for posting the data.
If you want to post the data then in that case please connect your extensibility team to create a custom rest based API to post the data
OData service is always an inbound service because you send request with get/post/put/patch/delete operation from any system and based on the request, that system will get response in same session from S/4HANA