Technical Articles
SAP S/4HANA Cloud Extensibility – Basics of creating, finding and using OData service in Custom Business Objects and Custom CDS Views
BLOG UPDATES IN PROGRESS!!
Last reviewed for Updates: January 17 2019
SAP S/4HANA Cloud Extensibility – Basics of creating, finding and using OData service in Custom Business Objects and Custom CDS Views
Target Audience – Users/ Developers/Business Experts/Key-Users of SAP S/4HANA Cloud
Blog applicability – SAP S/4HANA Cloud 1708, SAP S/4HANA Cloud 1711, SAP S/4HANA Cloud 1802 and SAP S/4HANA Cloud 1805
The theme of the Blog – This blog will answer following three questions-
- How to enable OData service for Custom Business Objects/Custom CDS Views
- How to know the name of the generated OData Service and enable it for consumption externally
- How to use the service after creating a Custom Business Object or Custom CDS Views and used it in Custom Communication Scenario
In some of the forums and projects, I have been often asked how to find out the OData service after we have created a Custom Business Object or a Custom CDS view in SAP S/4HANA Cloud system. In this blog, I will explain this and would also explain the usage and how to enable it for external consumption.
A note – If you are new to creating a custom business object, please refer to this blog here before reading ahead. And, if you want to gain more insights into the creation of Custom CDS views in SAP S/4HANA Cloud, please refer to this blog here before reading ahead.
Let us now understand why we need to know the service when working on S/4HANA Cloud. The answer to this question is – Integration and Extension of SAP S/4HANA Cloud. This means we can enable the resources in SAP S/4HANA Cloud for consumption externally. And for setting this up, SAP S/4HANA Cloud provides following tools-
Under Extensibility Group–
- We have the tile available called – Custom Communication Scenarios
Fig 1. Screen grab from Fiori Launchpad Extensibility Group
Under Communication Management Group–
- We have the tiles called – Maintain Communication Users, Communication Arrangement, Communication Systems
Fig 2. Screen grab from Fiori Launchpad Communication Management
These tools help in integrating SAP S/4HANA Cloud after we have set up the Inbound and Outbound communication and provided the OData service. At this point, we need to find out the name of the service and in this blog, we will learn this.
Example 1 – Let’s talk about a scenario where we need to maintain the Custom Business Object from outside the SAP S/4HANA Cloud system. This can be achieved by generating an OData Service on top of the Custom Business Object. Thereafter, you will call this OData service from an external client/Application and populate the Custom Business Object in SAP S/4HANA Cloud system
Example 2 – Another scenario can be when we want the data in Custom CDS View to be available outside of SAP S/4HANA Cloud system. An example of this is when having an application that displays the content of Custom CDS views created in SAP S/4HANA Cloud. To learn about this please visit this blog
The answer to both the above examples is – we generate OData service on top of a Custom Business Object and Custom CDS views.
How to enable the OData service?
In case of Custom Business Object, we need to select the option Service Generation. See example below-
Fig 3. Screen grab from Custom Business Object App
And, in case of a Custom CDS View, we need to select the option OData API. See below-
Fig 4. Screen grab from Custom CDS View App
Continue reading to know more about how to find the OData service name for a Custom Business Object and Custom CDS View.
How to know the name of the generated OData service?
In case of both Custom Business Object and Custom CDS views the service name is derived by adding the suffix ‘_CDS’ to it.
So, for example, if the name of the Custom Business Object is YY1_CUSTOMER_CBO, then the name of the generated service will be YY1_CUSTOMER_CBO_CDS.
And if the name of the Custom CDS view is YY1_SUPPLIER_INFO, then the name of the generated service will be YY1_SUPPLIER_INFO_CDS.
How to use the service in Custom Communication Scenario?
To use the OData service in Custom Communication Scenario, we first need to know the name which we have already learned above. Thereafter, you need to follow three steps in case of both Custom Business Object and Custom CDS Views-
Step 1: Include the service name in the Custom Communication Scenario
Step 2: Create a Communication Arrangement with a Communication User
Step 3: Transport all the objects and consume the service via an external system
Please see the following steps to create a Custom Communication Scenario and use your newly created OData Service for Custom Business Object.
- Open the Custom Communication Scenario App and Click on New
Fig 5. Screen grab from Custom Communication Scenario App
- Next enter the name for a Communication Scenario and a short description and click on New
Fig 6. Screen grab Custom Communication Scenario App
- In the next screen, you would see 3 different options-
Fig 7. Screen grab from Custom Communication Scenario App
Let us understand a little bit about these three options-
- Inbound Services – means when a resource or a design-time artifact from S/4HANA Cloud system is accessed from the external system or environment. For example, you have created a custom CDS view that fetches certain data and you would like to show it externally in some application
- Outbound Services – In simple words, say there is an external service provider and you would like to call that service from within the Custom Logic App or within the Custom Business Object. You can also use Outbound Services to update the data outside of your SAP S/4HANA Cloud System. Consider for example, within the S/4HANA Cloud system in your Custom Business Object you would like to get the updated currency conversion value and then update it in the field in CBO. In such cases, you can create an Outbound Service. To learn more about how to create and use an Outbound Service, please visit this link here
- Communication Arrangements – lists all the communication arrangements created for the custom communication scenario
- Let’s now create an Inbound Service. Select the tab Inbound Services and click on the + icon
Fig 8. Screen grab from Custom Communication Scenario App
- Now in the pop-up, we will provide the service name that was generated after we created our Custom Business Object. If you remember from section ‘How to know the name of the generated OData service’ we already know now that we need to compound the name of the CBO and add the suffix ‘_CDS’ to get the name of the service. We will provide the same in the Add Services pop-up. Select your service and click Ok
Fig 9. Screen grab from Custom Communication Scenario App
Fig 10. Screen grab from Custom Communication Scenario App
- The service would now be added
Fig 11. Screen grab from Custom Communication Scenario App
- In the next step click on Publish button to publish the service for this Custom Communication Scenario
Fig 12. Screen grab from Custom Communication Scenario App
With this your Custom Communication Scenario YYI_CUSTOMER_CBO_DEMO_CS is ready
OData Service for Custom CDS View
Similar to above example, a OData service would be created by compounding the name of the CDS view and adding the suffix ‘_CDS’.
For example, see below where the name of our CDS view is – YY1_ProductList, the OData service created for this one would be YY1_ProductList_CDS.
Fig 13. Screen grab from Custom CDS Views
And the name of OData service can be found when creating an Inbound Service under Custom Communication Scenario app
Fig 14. Screen grab from Custom Communication Scenario
The above is an example of creating, finding and using an OData service generated on top of a Custom Business Object and Custom CDS Views. To learn more and follow detailed steps for Custom CDS view, please visit this blog here and click on the section ‘Basics of setting up a Side-by-Side scenario in SAP S/4HANA Cloud’
Congratulations you have successfully learned the basics of why we need OData service, how to create it for Custom Business Object and Custom CDS views in SAP S/4HAHA Cloud!
Rohit Khan, S/4HANA Regional Implementation Group
Hi Rohit,
Thanks for this helpful blog. One question regarding capability of doing S/4HANA Cloud extensibility.
I read from other web sites saying that S/4HANA Cloud has two variants: running on single-tenant and multi-tenant.
The extensibility you mentioned here only apply to single-tenant but not multi-tenant.
Is this true? Thanks.
Regards,
Nick
Hello Nick,
Extensibility framework is supported in the single-tenant edition.
Regards
Rohit
Hello,
how do you configure OData Web Services for Multi-tenant then?
Is this not an option?
Thanks!
Hi Rohit,
Thank you for your post! One question... Is the custom business objects the substitute of traditional Z table?
Thanks!
Regards,
Javier
Hello Javier,
Yes you equate custom business objects to ztables. In addition they support generation of OData service using which you can access them outside of S/4HANA system.
Cheers
Rohit
Hi Rohit,
I have created a Custom Business Object without any errors as far as I can see. But in Transaction se16 for example I cannot find a new table with the created Business Object Name. How to find tables that I have created with the tile custom Business object.
Best Regards
Marcel
Hi Marcel,
After we create a CBO, the system internally generates a random name like ZZ1_0DA3591F4437 (for example). In this case, you would have to go and search using the CBO name and put it into the short description field in SE16 and you should be able to find the table created in the backend.
Hope this helps!
Regards
Rohit
Hi Rohit Khan ,
I would like to have an option only capital letters allowed similar to domains in SAP GUI. Is there any possibility In understand we need to explicitly write coding in the after save method. But other than that ?
Thanks,
Vijay
Hi Vijaya Simha Chintarlapalli Reddy ,
I am not very clear with your question. But as I interpret you want to allow only capital letters to be entered? If that is that case, then yes you are right and you can issue messages from there.
Cheers - Rohit
Hello Rohit,
Nice Blog !.
However, I have two questions.
Thanks,
Ankit
Hello Ankit,
OData Services cannot be consumed in custom CDS views nor in custom analytical queries. Custom CDS views can use C1 released VDM CDS data sources as well as most CDS views that are created from in-app extensibility tools (also the ones that are created for custom BOs).
Custom analytical queries can only use custom CDS views of type cube as well as C1 released VDM cubes as data sources.
Best Regards,
Andreas