This is Jerry’s 48th article in 2021, and the 325th original article on Wang Zixi’s official account in total.

Jerry’s previous article on SAP Fiori App Index describes a website that provides a list of all SAP Fiori apps.

As of July 18, 2021, SAP has released a total of 13,268 Fiori applications:



The number of Fiori applications that belong to SAP S/4HANA and whose UI is based on Fiori Elements is 878.

These 878 Fiori applications have been mentioned by Jerry in many previous articles. Their architecture is that the front interface adopts List Report, Object Type and other templates provided by Fiori Elements, and the business data is provided by OData service in the background.

SAP Fiori Elements Open Class Unit 1 video

SAP S/4HANA standard OData service, which can be queried and viewed in the SAP API Business Hub.



These OData services, in addition to being used for SAP S/4HANA standard Fiori applications, can also be invoked by SAP Partners in third-party applications for easy integration with SAP S/4HANA. For example, Partners can redevelop an application in a programming language they are familiar with and then deploy it to SAP BTP in what is known as side-by-side scaling.



OData protocol is based on HTTP. When using OData service to create or modify business data, programmers need to operate the body content of POST request at the HTTP level, which is cumbersome and error-prone. For example, the following is a test code snippet of Jerry’s 2019 project that uses Java to call SAP C4C OData service to create a sales order. The variable Body in line 88 contains the load content of manually splicing HTTP POST request, which is very unreadable and difficult to maintain.

To address these shortcomings and improve the efficiency of Partners’ integration with SAP S/4HANA Odata services, SAP has released the SAP S/4HANA Cloud SDK. The so-called SDK(Software Development Kit) is a collection of a series of Development tool libraries, including models and APIs out of the box.

With the help of SAP S/4HANA Cloud SDK, developers do not need to know the design details of S/4HANA Odata service. They can call S/4HANA Odata service with a code style similar to natural language to realize the requirements of data addition, deletion, modification and checking.

Currently the S/4HANA Cloud SDK supports both Java and JavaScript programming languages. On the SAP API Business Hub, we can download the Java version of the SDK:

This article introduces the JavaScript version of the S/4HANA Cloud SDK.

Run the following command to install the SDK:

npm install -g @sap-cloud-sdk/cli

Then create a new project using the command line:

sap-cloud-sdk init my-sdk-project

The structure of the automatically generated project file is as follows:

In the generated project, package.json defines the following dependencies:

The package.json file defines dependencies that, in addition to the SAP-cloud-SDK itself, include NestJS, a development framework for building efficient and extensible Node.js server-side applications.

The purpose of this paper is to use SAP S/4HANA Cloud SDK to consume the Business Partner OData service in the API Business Hub Sandbox system. If the real requirement is to consume the OData service of an SAP S/4HANA Cloud system, just change the URL in the code that points to the API Hub to point to S/4HANA Cloud Tenant.

As mentioned above, with the Cloud SDK, developers do not need to know the S/4HANA OData design details, because these details are encapsulated by the so-called Virtual Data Model in the Cloud SDK: the Virtual Data Model, or VDM. The data model used by each SAP S/4HANA Odata service is encapsulated in the corresponding NPM package in the Cloud SDK, and developers can import it as needed.

In order to consume the Business Partner OData service, we searched the SDK NPM package on SAP’s official website:

Search by keyword Partner to find the installation package and copy its ID: @SAP /cloud-sdk-vdm-business-partner-service.

Install it locally by executing the following command line:

npm install @sap/cloud-sdk-vdm-business-partner-service

Now there is an additional dependency in package.json that points to the package:

The following is the complete code of using Cloud SDK to query the first two Business Partner data of API Hub Sandbox system, and the core code is only about ten lines:

  • Line 2 imports the virtual data model named BusinessPartner from the downloaded BusinessPartner VDM package
  • Line 15 calls the RequestBuilder method of the BusinessPartner model to construct an OData data request. The chain calls to getAll and top(2) are then used to specify a specific target for the constructed OData data request: return the first two data.

It’s not hard to see that the code here doesn’t have any parts that directly manipulate HTTP, but more of a natural language style. A business consultant with no background in development can read and guess what this code does.

Start the application from the local command line:

npm run start:dev

Two Business Partner data can be retrieved successfully when tested in the browser:

There are corresponding methods for operations supported by OData protocol in Cloud SDK VDM.

For example, the ODATA protocol SELECT directive only returns the specified field, which corresponds to the SDK SELECT method of the same name:

Execution effect:

OData protocol filter instruction, corresponding to the SDK filter method of the same name.

The following code means that only the first 20 Businessner-types are returned if the Businessner-Category field has a value of 2:

I hope this article can give you a basic understanding of SAP S/4HANA Cloud SDK. If you need to use the SAP Cloud SDK to integrate with SAP S/4HANA Cloud, it is recommended that you start from the SAP official website and learn step-by-step.

Thanks for reading.

https://sap.github.io/cloud-s…

More of Jerry’s original articles can be found on “Wang Zixi “: