Skip to Content
Technical Articles
Author's profile photo Dharam Verma

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)

Figure 1


Click on create for a new CDS view.(Figure 2)

      Figure 2


Now, give any label, name would be created automatically.

Select scenario as External API(Figure 3)

                     Figure 3


Now here we need to add data source, data source can be standard or custom.

First let’s add primary data source.

Here, I have added “I_Supplier” which gives the supplier details including supplier AddressID.(Figure 4)

           Figure 4


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 associated data source, set the join condition.(Figure 5)

            Figure 5


Here we can choose any field on associated data source and then select operator like equals, set value type as parameter, field(from primary data source) or constant(Figure 6)

        Figure 6

Here I am adding AddressID field from associated data source, condition equals to AddressID field of primary data source (Figure 7)

      Figure 7


After adding data sources, next step is to add parameters, but we can’t add parameters when Scenario is “External API”.

So, let’s move to the next step which is adding elements from both or all data sources.(Figure 8)

            Figure 8


After adding elements, just click on publish and wait until status changes to “Publishing Successful”.(Figure 9)

           Figure 9

After Successful Publishing, now we can check the result in terms of data.(Figure 10)

                                     Figure 10


Now, we need to create Custom Communication Scenario for the created Custom CDS View so that same CDS view can be used as an External API

Go to Extensibility-> Custom Communication Scenarios(Figure 11)

Figure 11


Click on new(Figure 12)

        Figure 12


Put any name for scenario ID.(Figure 13)

                            Figure 13


Now add CDS view (Figure 14 and 15)

          Figure 14

           Figure 15



Publish it (Figure 16)

                 Figure 16


After successful publishing on custom communication scenario, we can add it to Communication Arrangement.(Figure 17)

        Figure 17


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



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Prathish Reddy
      Prathish Reddy

      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.

      Best regards,


      Author's profile photo Dharam Verma
      Dharam Verma
      Blog Post Author

      Hi Prathish,

      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

      Please check this blog

      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