Technical Articles
S/4HANA Extensibility: How to Find APIs and Extension Points
APIs, APIs, APIs: when building an extension for a product like S/4HANA, in the end it is all about APIs and about extensions point, meaning points where you can hook into existing applications and processes.
In my previous blogs, I wrote about the tools that you can use for extending S/4HANA (see, for example https://blogs.sap.com/2015/09/30/the-key-user-extensibility-tools-of-s4-hana/). In this blog, I want to guide you through the tools where you can find the related APIs and extension points.
External (Web Service) APIs
External APIs (Web Service) are listed on the SAP API Hub. You can find them under https://api.sap.com/ -> API Packages -> SAP S/4HANA Cloud and SAP Hybris Marketing Cloud. These APIs can be used for integration and side-by-side extensibility for example on SAP Cloud Platform. For additional information, read also my blog on https://blogs.sap.com/2016/10/19/s4hana-extensibility-connect-sap-s4hana-cloud-sap-hana-cloud-platform-hcp/.
You can see here the screenshot with the list of S/4HANA APIs (more than 170 at the time of revisiting the API hub in May 2018, and but I expect that this number still increasing)
Let me add some information about the differences between On-premise and Cloud:
In SAP S/4HANA Cloud, each API comes with a communication scenario (typically with a technical name SAP_COM_xxxx) that is indicated in the detailed screen of an API together with the documentation. You can use the the name of the communication scenario to activate the service as described in my blog https://blogs.sap.com/2016/10/19/s4hana-extensibility-connect-sap-s4hana-cloud-sap-hana-cloud-platform-hcp/. Together with the communication scenario, SAP deliveres a user role and additional configuration content that is applied when creating the communication arrangement.
In SAP S/4HANA (on-premise) you have to do some configuration steps. If the API is of type OData, go to the OData Gateway, call transaction /IWFND/MAINT_SERVICE, click Add, select a backend system. If the service is available in the backend system, you can configure it. Then you have to define a role and a technical user to be able the call it. (This is what is automated by the comm scenario in S/4 HANA Cloud). For details, please refer to the Gateway documentation. If the API is a SOAP API, then you have to do the “usual” steps to configure a SOAP API.
In general, APIs that are available in S/4HANA Cloud are also in the on-premise version in a “Cloud first” way: this means SAP is shipping quartely Cloud releases and the on-premise version that is shipped once a year will contain the APIs of the previous Cloud versions.
CDS/VDM Views
CDS/VDM Views are the S/4HANA read APIs for in-app extensibility. You can use them
- to build new analytical apps (so-called cubes and queries, and on top of them analytical reports and KPIs)
- in custom code extensions (“BAdIs”)
- to build your own custom CDS views and expose these views as OData service as external API.
You can see all released CDS Views in the following tools:
- View Browser Fiori app
- Custom CDS Views Fiori app (released CDS views except analytical queries)
- Custom Analytical Queries Fiori app (released CDS views of type analytical query)
- ABAP Development Tools for Eclipse: “Released Objects” Repository tree
The first three tools are available in Cloud and on-premise, the Eclipse tool is available in on-premise only.
The following screenshot shows the View Browser (contained in the Fiori catalog SAP_CA_BC_ANA_AQD_PC in SAP S/4HANA Cloud).
You can open the details screen a CDS view and inspect the view properties. In the Fiori app Custom CDS Views and Custom Analytical Queries, you can also do a data preview in this app.
The following screenshot shows the “Released Objects” Repository tree in ADT:
You can configure the tree in Eclipse with: New Repository Tree -> Released Objects
When updating this blog, there were >1300 released CDS views available.
You can find also documentation on CDS/VDM Views in the S/4HANA product assistance (https://help.sap.com -> SAP S/4HANA Cloud) -> Product Assistance -> Extend and Integrate Your SAP S/4HANA Cloud -> Virtual Data Model and CDS Views in SAP S/4HANA Cloud -> CDS Views).
You can also find information on released CDS view on SAP API Business Hub, Content Types, CDS Views.
What is CDS and VDM? In short, we can say that CDS is a technology, while VDM stands for the semantical model.
CDS (Core Data Services) is a key component of the SAP technology for levering qualities such as:
- Capture and share business-rich data models using the SAP HANA relational model
- Enrich the data models with specific semantics e.g. for UI, draft, analytics, search, actions and events. It’s also enabling the S/4HANA APIs
- Leverage SAP HANA optimally in most relevant scenarios
- Enable and standardize esp. zero downtime, verticalization, extensibility, access control (based on ABAP authority objects)
- Integration into ABAP programming model and improve development productivity
- Exposure of CDS models and data to SAP Cloud Platform, e.g. for Business Objects Cloud and extension apps
SAP Virtual Data Model (VDM) represents the simplified and harmonized business oriented semantically enriched data model. “Virtual” refers to the fact that the VDM semantical model may deviate from the historically grown persistent model of database tables to make it simpler and easier to understand. In SAP S/4HANA, the VDM is established by specifically classified/annotated CDS Views.
This is a short impression, the complete CDS/VDM story is a subject for a subsequent blog.
Analytical Queries
Analytical Queries are the base objects for analytical UIs (KPIs and Reports). Technically they are also CDS/VDM View, but with a very specific semantics. You can see all released SAP Analytical Queries in the overview page of the Custom Analytical Queries app.
Business Contexts for Custom Fields and Logic
Business Contexts are SAP entities that can be extended by custom fields and/or custom logic. Typically, business contexts represent “business document tables” or “business object nodes”, Examples for extensible business contexts are: Billing Document, Billing Document Item, Billing Due List Item.
You can find the list of extensible business context in the Extensibility Cockpit Fiori app (in Fiori catalog SAP_CA_BC_EXT_COCKPIT_PC) with this app, you can explore all business contexts that are enabled for field extensibility and the related data sources, services, enhancement options, etc. Or you can find them in the Custom Fields and Logic Fiori app.
The following screenshot shows the Extensibility Cockpit Fiori app:
When revisiting the app during my lat update of this blog, I was seeing >180 business contexts enabled for custom field and/or logic enhancement.
You can also start your investigation by Fiori app: In the Fiori Appl Library ( Fiori Apps Library ) you can find the information on the extensibility for Fiori apps. Open the App Details for a Fiori app, and go to section Implementation Information, Extensibility.
For example select SAP Fiori Apps for SAP S/4HANA, All Apps, find “Manage Purchase Orders”, go to section Implementation Information, Extensibility. Here you can find the technical information in the UI (“BSP containing SAPUI5 application”) and the link to the extensibility documentation. In the extensibility documentation you can find the business contexts, that belong to the Fiori app and additional information, such as information on BAdIs (but not necessarily the complete list of all BAdIs, which is available in the Extensibility Cockpit).
Class APIs
Class API can be used in custom logic as re-use methods. When writing this blog, there is no browser for class APIs available. You must go into the coding and use the code completion (cntrl + blank) to see the available class API together with its signature.
In total, there are >80 class APIs available at the time of updating this blog.
Summary
SAP has defined the API hub as the central place for publishing all external APIs. The publishig of APIs for S/4HANA has started, I exect more an more APIs appearing here.
For in-app extensibility, internal APIs (CDS views and classes) and extension points are used. A central tool for discovery is still missing, so for the time being you must use different tools when searching for APIs and extension points. This should be fixed by a central tool in the future. I will be happy to report on the discovery tool in a future blog once this is available.
Hi Thomas,
Thanks for sharing, i have two questions can you clarify
Thanks,
Muruga
Hi Muruga,
Hi Thomas,
Thanks for your update, in S/4HANA on premise how we can write ABAP code in CDS view? i am looking for this can you show some light to this.
Thanks,
Muruga M
Hi Thomas,
Thanks for the blog. I can see in the example that you can access CDS views and Class APIs in Custom Business Object. But I just wanted to know if External whitelisted APIs can be used as well. I read in one of your earlier blogs where Marketing Edition was using some OData service from 3rd party to populate data in its custom object. There is also a demo video of how a custom object stores Twitter data, but again the demo doesn't show how its technically done.
Is there any example, blog or code-snippet which shows in detail how to do this? It will be really helpful.
Regards,
Arun.
Hi Arun,
the demo was build with the help of SAP Cloud Platform Integration Services (fka HCI). So HCI is pulling data out of the external source and pushing it into the Custom BO via OData service. So a call from the Custom BO into an external service is not involved (it is on our backlog, but not available yet).
Best regards,
Thomas
.
PS: Here, you can find a blog post from a colleague that describes hto work with the OData services of a custom BO: https://blogs.sap.com/2017/05/12/usage-of-odata-service-of-custom-business-object/
Hi Thomas ,
I would like to know about API's associated which can be used for the interaction.
sorry, I do not understand the question
Hi Thomas Schneider
I am very new to this. Could you please confirm whether my below assumption is true?
The API's are meant for integrating S/4HANA Cloud solution with other SAP products (Cloud or On-premise) and 3rd party products. For S/4 HANA on-premise version, we don't have such API's, and the external system has to use other methods like OData service to communicate with them.
Thanks,
Johann
Hi Johann,
what I heard is that the API's are meant to offer extensibility to S/4HANA Cloud editions, however the basis for the API's are function modules which are also available in an on-premise system. This would be a nice setup because then you could develop extensions that work with both on-premise and cloud S/4HANA systems.
So the question is: Can these API's be setup for an on-premise system in the same way as a cloud system would offer them?
Hopefully Thomas can shed some light on this scenario, would be very interesting to understand the architectural setup behind the API's 🙂
Regards,
Benjamin
Thank you Benchamin for the reply. Most of the SAP document/blog mentioning S/4Hana API, focuses on Cloud version only. They don't say clearly whether or how this can be used in on-premise version. So as a newbie like me, it's too difficult to understand.
Hi Johann,
the APIs are available in S/4HANA Cloud and also in the on-premise version (Cloud first: means SAP is shipping quartely Cloud releases and on-premise once a year). So, the difference ist not the APIs. But in Cloud, you get them as prepackaged content, whihc is not available in on-premise.
Best regards,
Thomas
.
Hi Thomas,
when you say they are not available as prepackaged content, this means that there is a way to configure them manually in an on-premise system, correct? Do we have some documentation on how one would configure an on-premise system to offer (some of the) APIs in a comparable way? At this point I am looking for the API called "Process Material Documents", but there will be a need for others as well.
Thanks for any clarification.
Best regards,
Benjamin
Hi Benjamin,
let me take your example to explain a bit on the differences between SAP S/4HANA Cloud and on-premise. (Please note that this is not an official documentation but just my "experience").
1) If you open SAP API hub (https://api.sap.com/shell/api) and enter "Process Material Documents" into the search bar, you get the following screen that describes the API in SAP S/4HANA Cloud:
As mentioned this documentation is relevent for S/4HANA Cloud, but as the Cloud and the on-premise version have the same codeline, it should be also available in the on-premise version that was shipped after the release of this API. But you need to check in your On-Premise system. This depends, of course on the version of the on-premse system. You can, of course, also check the documentation of the on-premise system.
2) In S/4HANA Cloud you can easily configure the API using the preshipped content that is provided in the communication scenario Material Document Integration (SAP_COM_0108) and which is documented in the link behind Scope Items ("Stock Handling - Rework, Scrap, Blocked Stock (BMC)"). This is related to S/4HANA Cloud only.
For the on-premise scenario, you can do the following:
As this is an OData API, go to the OData Gateway, call transaction /IWFND/MAINT_SERVICE, select a backend system. If the service is available in the backend system, you can configure it. Then you have to define a role and a technical user to ba able the call it. (This is what is automated by the comm scenario in S/4 HANA Cloud). For details, please refer to the Gateway documentation.
If the API would be a SOAP API, then you would habe to do the "usual" steps to configure a SOAP API.
So if I'm coding in ABAP in S4 on premise, I have to call an odata service on the gateway in order to use a standard "api"? There is no corresponding call I make within S4 itself? If that's the case, the S4 system has no direct visibility to that service to facilitate coding. Meaning, no code completion, patterns, etc. Is that correct?
No. When you are coding in ABAP, you would use of course the other APIs mentioned in this blog: CDS/VDM views and Class APIs
I'm not sure how helpful the class api's are if they are not documented. I would have hoped that the coding being done to support all the odata services could be leveraged internally with the S4 stack so as to reduce redundancy and discrepancies. Meaning that any external call to the odata service would be assured of going through the same code logic as something called from within S4 abap.
CDS/VDM only help me in read situations. The vast majority of our coding customization is stringing together multiple calls(Call transaction, bapis, etc). I was hoping that the future would provide a better solution to the different methods to do that.
Hi Michael,
for "read" I would recommend: use the released "I_"-Views which correspond to the OData-Services. Typically they have the same or a similar name as the OData entity (starting typically with "A_"). As the naming conventions of S/4HANA follow a global field catalogs, the field names are normally the same in the OData service and in the CDS-View. You can see this, for example, nicely in the the OData service Product Master Integration or other "modern" OData service. For example
OData entity CDS View Table
(in the Product Master Integration OData service)
A_Product -> I_Product -> MARA
A_ProductSales -> I_ProductSales -> MARA/MAV1
A_ProductPlant -> I_ProductPlant -> MARC
...
for "write" I would recommend: as of today, use the well-known function modules or BAPIs for write. They are well established in the SAP community. And they are even more flexible in the "local" scenario because the OData service is always a transactional unit. In the case of the function modules or BAPIs, you can orchestrate mutliple calls in one transaction.
This may change in the future, but I think, for the time being, many developers may want to stick to the traditional programming model for the write use case.
Thomas Schneider ,
Can we create custom API's in cloud?
Hi Johann,
yes, you can use the Custom CDS Views app to create custom OData services in SAP S/4HANA Cloud.
please refer to my blogs:
https://blogs.sap.com/2015/09/30/the-key-user-extensibility-tools-of-s4-hana/ -> Custom CDS Views
https://blogs.sap.com/2016/10/19/s4hana-extensibility-connect-sap-s4hana-cloud-sap-hana-cloud-platform-hcp/
Best regards,
Thomas
.
Thank you
Hi Thomas,
Thanks a lot for your sharing, I have a question regarding native enhancement implementation(in-app extension) in S/4 Cloud. If I can find a proper business context and enhancement option(e.g. for sales order), is it possible I can implement some logic to update other business object directly(standard BO or custom BO, here if I'd like to update former document or store some value into custom BO I created after releasing SO). What you mentioned in blog is there is no browser or document I search what predefined class API can be used for certain enhancement point of business context and most of class API seems to be for only read purpose. I know calling a BAPI or updating table using SQL is not possible in S/4 Cloud, but I expect there would be some way we can do some custom modification like what normally did in traditional ERP/S4 previously. Now the only solution for any particular custom logic to enhance standard SO function is built a side-by-side extension on SAP Cloud platform to orchestrate available API for SO and OData for custom object into one transaction.
Regards,
Chenxi
Hi Chenxi,
you have to distinguish:
Best regards,
Thomas
Hi Thomas,
Thanks for your reply, so, the only way to achieve the enhancement based on standard SO transaction in case of any requirement on additional update other standard object or CBO is to build a whole new transaction for sales order in SAP Cloud Platform like copying the fiori UI, orchestrating OData API of sales order and APIs for custom objects to update them all in one transaction, is that right?
Regards,
Chenxi
Yes, this would be one valid option, in particular, if you need a complete new UI and lots of custom functionality.
But, if you only want to create a custom / SAP business object from a standard enhancement option (BAdI) you can request that the BAdI is enhanced accordingly or to request a write API from a standard SAP BO.
You can find the request process here: https://launchpad.support.sap.com/#/notes/2483157
Best regards,
Thomas
.
Extension Points in SAP Fiori apps - as seen in the corresponding SAPUI5 project in SAP Web IDE:
We are working on implementing S/4HANA Cloud. I took the SAP course UX402 on SAPUI5 development. In that course, we were able to pull a copy of the source code of an SAP Fiori app from S/4HANA (on-prem) to SAP Web IDE on our trial version of SAP Cloud Platform and then extend the Fiori app by creating an extension project in SAP Web IDE. We would like to do the same, but from S/4HANA Cloud. Do you know of any documentation on this?
In class, we used SAP Web IDE on a trial version SAP Cloud Platform with S/4HANA on-prem: Could we do the same with S/4HANA Cloud as the target? Also, we noticed that there is an 'SAP Web IDE' tile in S/4HANA Cloud's Fiori Launchpad: What is the purpose of this app, and could it be used to extend a standard SAP-delivered Fiori app?
Hi Steve,
for S/4HANA Cloud, extending UIs via extension project in SAP Web IDE is not supported. You can use the "Adapt UI" functionality for adapting UIs in S/4HANA Cloud (described in my blog https://blogs.sap.com/2015/09/30/the-key-user-extensibility-tools-of-s4-hana/ -> UI Flexibility.
Best regards,
Thomas
.
Thanks for clearing this up, Thomas. Is there any way we can at least view the source-code of a standard SAP Fiori app?
S/4HANA (on-premise) -> Yes
S/4HANA Cloud -> No (you cannot load the Fiori UI source code into SAP Web IDE, Of course, the source code is in the browser)
Thanks again, Thomas. This information is very helpful.
Thank you for the excellent information on S/4HANA extensibility options.
Very helpful..
--
Venu
Great article @Thomas_Schneider,
I would like to know if you have some details of the consumption model of the white listed API in the context of S/4HANA Single Tenant Edition (STE).
I assume the consumption is similar to on-prem scenario, but just want to double check with you and also know if you have any guide.
Thanks,
R
very helpful article Thomas Schneider. All your blogs are excellent usually. gives lot of insights.
Please, can you help me with some below information on STE as well. it will be of great help.