SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Connect to OData Service on Cloud Foundry Using SAP Cloud SDK

Create a basic Java project to call OData services using the SAP Cloud SDK on Cloud Foundry.

Overview

🎓 intermediate 20 min. SAP Cloud SdkIntermediateSAP Business Technology PlatformSAP Cloud Platform ConnectivitySAP S 4hanaCloudJavaOdata
Junjie Tang J Junjie Tang May 15, 2025
Created by August 14, 2019
Contributors

Prerequisites

Prerequisites

In order to follow this tutorial successfully, you need a working and reachable system of SAP S/4HANA on-premise or S/4HANA Cloud. You may substitute the business partner service introduced here with any other API published on the SAP Business Accelerator Hub. ย  If you do not have an S/4HANA system available, you may use a public service, such as the Northwind OData Service as a fallback solution. ย  This tutorial requires access to an SAP ERP system or, as a fallback, a mock server providing the Business Partner OData V2 service. ย  Alternatively, you can also use the Sandbox service provided by the SAP Business Accelerator Hub.

Steps

Intro

If you want to follow this tutorial, it is highly recommended to check out the previous tutorials in the series. You will not need any additional software besides the setup explained in the first part of the series.

Please note that depending on the platform you are using, the configuration to the respective S/4HANA system might be different. In this tutorial, you will be using BASIC Auth with which you can access your S/4HANA Cloud system on Cloud Foundry.

Note that your application code is not dependent on the platform you are using. Using the SAP Cloud SDK, you can write your code once, and it will be capable of dealing with all different authentication and connectivity options.


Step 1 Get access to Business Hub sandbox (optional)
โ€”

If you have access to an SAP S/4HANA Cloud system with a technical user, you can skip this part.

In order to make a call to an OData service, there needs to be a service to call.

Many OData APIs can be tested using the sandbox of the SAP Business Accelerator Hub. To use the sandbox, you need an API key. Go to https://api.sap.com and click “Log On” in the top right corner. If you do not have an account, you will need to register first. When you are logged in, click on the Business Partner OData V2 API reference and find you API key under “Show API Key”. You will use your API key later in this tutorial. The sandbox service URL can be found in Try Out > Code Snippet > Java > URL (in the code):

Make sure to use only the part before /sap/opu/odata/....

Sandbox URL
Sandbox URL

Step 2 Virtual Data Model
+
Step 3 Generate an OData client
+
Step 4 Use the generated OData client
+
Step 5 Write the BusinessPartnerController
+
Step 6 Deploy the Project
+
Step 7 Integration test for BusinessPartnerServlet
+
Step 8 Test class
+
Step 9 Troubleshooting
+
Step 10 Test yourself
+
Step 11 Test yourself
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 11
1. Get access to Business Hub sandbox (optional) 2. Virtual Data Model 3. Generate an OData client 4. Use the generated OData client 5. Write the BusinessPartnerController 6. Deploy the Project 7. Integration test for BusinessPartnerServlet 8. Test class 9. Troubleshooting 10. Test yourself 11. Test yourself

Learn more →