Skip to the content.

OData Mock Service

This repository also contains a simple Node.js-based server that represents an OData mock server in the branch mock-server. The server makes it possible to test the SAP S/4HANA integration capabilities of the SAP S/4HANA Cloud SDK described in the book without access to an SAP S/4HANA system. The server hosts an OData v2 mock service that mimics the business partner API of SAP S/4HANA Cloud to a limited extent.

The mock server can be used as a stand-in for simple tests and experiments with the SAP S/4HANA Cloud SDK if no SAP S/4HANA system is available. It is especially tailored towards the examples found in the book. This page explains how to run the mock server and how to integrate it into the tests of the sample application.

Note: the server is not secured in any way. Run the server at your own risk and only for experiments. Do not use the server to store any personal data - only use fake data.

How to run the server

When you have cloned this repository, checkout the branch mock-server. Alternatively, download this archive and unzip it to your local machine. All of the following steps shall happen in this folder where you checked out or extracted the code of the mock server.

Before you can launch the mock server, you need to manually put the metadata EDMX document of the business partner OData service into the folder business-partner and prepare the document:

<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"/>

After you have thus prepared the mock server, you can run the mock server on your local machine (at http://localhost:3000) or on SAP Cloud Platform, Cloud Foundry, as described in either of the following two sections.



The following tools need to be installed on your local machine.

Launch the mock server

Execute the following commands in a command line shell of your choice within the folder where you stored the artifacts:

npm install
npm start

Wait until you see the output Mock server started. Access the mock OData service at http://localhost:3000/sap/opu/odata/sap/API_BUSINESS_PARTNER (no credentials required). This should have the following output.


To see an example response of business partners, visit http://localhost:3000/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner.

On SAP Cloud Platform, Cloud Foundry


The following tools need to be installed on your local machine.

Launch the mock server

Execute the following commands (this assumes that you have set up your Cloud Foundry account at region EU10):

cf api
cf login
cf push

Watch the output of the command for the URL of the Cloud Foundry app. Look for a line towards the end similar to the following:

urls: bupa-mock-odata-<random-route>

Access the mock OData service at that URL, by appending the path /sap/opu/odata/sap/API_BUSINESS_PARTNER.

Use your specific URL like https://bupa-mock-odata-<random-route> as the URL for your destination ErpQueryEndpoint with any dummy user and password (or choose No Authentication when defining the destination with the destination service on SAP Cloud Platform).

Connect your application to the mock server

Run the application locally

Before running your application using the SAP S/4HANA Cloud SDK locally, you need to set the environment variable destinations as follows to connect the application to the mock server. Username and password can have any value. The URL should point to the location of your mock server instance, e.g. the local URL (http://localhost:3000) or the URL of the deployment of the mock server to SAP Cloud Platform.

Afterwards, start the application in the same session with mvn clean package tomee:run (within the application folder).

Deploy the application to SAP Cloud Platform

To deploy the application to SAP Cloud Platform and connect to an mock server instance configure the destination service on SAP Cloud Platform or define an environment variable in the manifest.yml:

- name: address-manager
  destinations: [{'name': 'ErpQueryEndpoint', 'url': '', 'username': 'DUMMY', 'password': 'dummy'}]


As a mock server, the functionality of the mock OData service is limited to the most essential features. It is by no means a complete OData service compliant with the OData v2 specification. Also, it is beyond the plain API not comparable with the business partner API of SAP S/4HANA Cloud.

Consider the following detailed limitations:

Supported OData operations and capabilities

The OData mock service supports the following features centered around the API_BUSINESS_PARTNER, and thus allows to test certain scenarios using this mock server instead of an SAP S/4HANA system:

Also see the accompanying test suite in folder integration-tests, implemented as Java JUnit tests using the SAP S/4HANA Cloud SDK, specifically its Virtual Data Model (VDM).