website

OData Mock Service

The repository also contains a simple Node.JS based server that represents the OData emulation server in the branch emulation server. The server can test the SAP S/4HANA integration features of the SAP S/4HANA Cloud SDK without accessing the SAP S/4HANA system. The server hosts an OData V2 emulation service that mimics the SAP S/4HANA Cloud’s business partner API to some extent.

If no SAP S/4HANA system is available, the simulation server can be used as a substitute for simple testing and experimentation with the SAP S/4HANA Cloud SDK. It is tailored specifically to the examples in this book. This page explains how to run the mock server and how to integrate it into the tests for the sample application.

Note: The server has no security measures. Running the server is at your own risk and is for experimentation only. Do not use the server to store any personal data – only use fake data.

How to run the server

After cloning this repository, check the branch emulation server. Alternatively, download the archive and unzip it to your local computer. All of the following steps should take place in the folder where you check out or extract the mock server code.

Before starting the mock server, you need to manually place the metadata EDMX document for the business partner Odata service into the folder Business-Partner and prepare the document:

  • Go to the description of the business partner API in the SAP API Business Center.
  • Click Login and log in with your credentials (you may need to register beforehand).
  • Click the Details TAB, then click Download the specification and select EDMX.
  • Store the downloaded file named api_business_partner.edmx in the subfolder Business-Partner of the emulated server folder.
  • Open the file api_business_partner.edmx in a text editor and find the line that contains EntityType Name=” A_BusinessSpartnerType “. In this EntityType, add the following two lines after the line containing \ :
<Property Name="YY1_AddrLastCheckedOn_bus" Type="Edm.DateTime" Precision="0" sap:display-format="Date" sap:label="Addresses Last Checked On"/>
<Property Name="YY1_AddrLastCheckedBy_bus" Type="Edm.String" MaxLength="50" sap:label="Addresses Last Checked By"/>

Once you have the mock server ready, you can run it on your local computer (http://localhost:3000) or on the SAP Cloud Platform, Cloud Foundry, as described in either of the following two sections.

Launch the mock server

npm install

npm start

Wait until you see that the output Mock server is started. At http://localhost:3000/sap/opu/odata/sap/API_BUSINESS_PARTNER access to simulate OData services (don’t need credentials). This should have the following output.

{"d":{"EntitySets":["A_BusinessPartner","A_BusinessPartnerAddress"]}}

To view the sample response business partners, please visit http://localhost:3000/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner.