Sub topic 14
SAP BTP for side-by-side extensions and integration
This chapter assumes you know the three S/4HANA editions, the clean core principle, and the in-app and developer extensibility models from earlier chapters. You should also know what an OData API is. Here you will see how SAP Business Technology Platform (BTP) lets you build and connect things next to S/4HANA instead of inside it, and how that differs by edition.
What side-by-side means
A side-by-side extension is an application that runs outside the S/4HANA system, on SAP BTP. It talks to S/4HANA only through released interfaces: OData or SOAP APIs and business events. It has its own lifecycle, its own database, and its own deployment pipeline.
This keeps the S/4HANA core clean. The core is never modified, so its upgrades are not blocked by your code. The cost is that the extension is a separate system. It needs its own authentication, error handling, monitoring, and data model.
BTP is also the integration hub. Even when you build nothing, you can use it to connect S/4HANA to other systems.
What BTP provides for this
| BTP capability | Role in an S/4HANA scenario |
|---|---|
| Cloud Foundry or Kyma runtime | Hosts your extension application |
| SAP Cloud Application Programming Model (CAP) | Framework for services and data models, in Node.js or Java |
| ABAP environment | Runs ABAP Cloud code in a separate system, with its own lifecycle |
| SAP Build | Low-code apps, workflows, and automation |
| Destination service | Stores the URL and credentials of a target system |
| Connectivity service and Cloud Connector | Secure tunnel to systems that are not reachable from the internet |
| SAP Integration Suite | Prebuilt integration flows, API management, event handling |
| SAP Event Mesh or Advanced Event Mesh | Receives business events from S/4HANA |
You do not need all of these. A small extension often uses only a runtime, the Destination service, and one API.
How the connection differs by edition
The extension model is the same in all three editions. The network path and the way you grant access are different.
| Row | Public Edition | Private Edition | On-premise |
|---|---|---|---|
| Network reachability | Internet-facing HTTPS endpoint | Usually private, reached through Cloud Connector or a private network link | Behind the customer firewall, reached through Cloud Connector |
| Access setup | Communication scenario, communication system, communication user, bundled in a communication arrangement | Standard ABAP roles and users, with a service activated in the gateway | Same as Private Edition |
| Available APIs | Released APIs only | Released APIs recommended. Classic and unreleased interfaces also exist but break clean core | Same as Private Edition |
| Side-by-side is | One of three extensibility paths, and the only one for large custom applications | Optional. Classic ABAP extensions are still possible | Optional. Classic ABAP extensions are still possible |
In Public Edition you cannot add ABAP code to the core in the classic way, so a side-by-side app is the standard answer for anything that does not fit in-app or developer extensibility. In Private Edition and on-premise you could write the logic in the core. Side-by-side is a choice you make to keep the core clean and the upgrade path short.
Calling an S/4HANA API from a CAP application
The example below exposes a read-only list of business partners. The data comes live from the released API API_BUSINESS_PARTNER. You can find the API definition in the SAP Business Accelerator Hub. Download its EDMX file and import it with cds import. The Destination service holds the connection, so no URL or password appears in the code.
First, the CAP configuration in package.json:
{
"name": "partner-ext",
"version": "1.0.0",
"dependencies": {
"@sap/cds": "^8",
"@sap-cloud-sdk/http-client": "^3",
"@sap-cloud-sdk/connectivity": "^3",
"@sap-cloud-sdk/resilience": "^3",
"express": "^4"
},
"cds": {
"requires": {
"API_BUSINESS_PARTNER": {
"kind": "odata-v2",
"model": "srv/external/API_BUSINESS_PARTNER",
"credentials": {
"destination": "S4_BACKEND",
"path": "/sap/opu/odata/sap/API_BUSINESS_PARTNER"
}
}
}
}
}Next, the service definition in srv/partner-service.cds:
using { API_BUSINESS_PARTNER as bp } from './external/API_BUSINESS_PARTNER';
service PartnerService {
@readonly
entity Partners as projection on bp.A_BusinessPartner {
key BusinessPartner,
BusinessPartnerFullName,
BusinessPartnerCategory
};
}Last, the handler in srv/partner-service.js forwards the query to the remote service:
const cds = require('@sap/cds');
module.exports = class PartnerService extends cds.ApplicationService {
async init() {
const bp = await cds.connect.to('API_BUSINESS_PARTNER');
this.on('READ', 'Partners', req => bp.run(req.query));
return super.init();
}
};The destination S4_BACKEND is created in your BTP subaccount. For Public Edition it points to the system URL and uses the communication user from your arrangement. For Private Edition or on-premise it points to the virtual host defined in the Cloud Connector.
Events instead of polling
Polling an API every minute wastes calls and still reacts late. S/4HANA publishes business events, for example when a business partner or a sales order changes. The event carries the key of the changed object, not the full data. A typical flow is:
- S/4HANA raises the event, and the event broker on BTP receives it.
- Your extension subscribes to a queue and receives the key.
- The extension calls the released API with that key to read the current state.
Because events can be delivered more than once and out of order, the handler must be idempotent. Read the current state from the API instead of trusting the order of events.
Integration beyond extensions
SAP Integration Suite sits between S/4HANA and other systems, such as a CRM, a bank, or a supplier network. Three uses matter most:
- Integration flows map and route messages between systems, for example IDoc or SOAP on one side and REST on the other.
- API management places a gateway in front of your own APIs, with throttling, authentication, and analytics.
- Prebuilt content from the Integration Suite catalog covers common SAP-to-SAP scenarios, so you configure them instead of building them.
In Public Edition, SAP's guidance is to integrate through released APIs and events, and Integration Suite is the usual way to do that. In Private Edition and on-premise, older point-to-point connections such as RFC and IDoc still work. They tie you to the internals of the system, so new integrations should still prefer released APIs where one exists.
Common errors
- 401 or 403 from the API. The communication user lacks authorization for the communication scenario, or the scenario does not include the API you call. Check the arrangement first, not your code.
- Destination works in the browser but not from the app. The app is not bound to the Destination service instance, or the destination is in a different subaccount.
- Cloud Connector shows the host as unreachable. The virtual-to-internal host mapping is missing, or the resource path (here
/sap/opu/odata/sap/API_BUSINESS_PARTNER) is not exposed in the Cloud Connector access control. - Extension breaks after an S/4HANA upgrade. It used an API that was not released, or a released API that was deprecated. Released APIs carry a lifecycle state, and the Business Accelerator Hub shows it.
- Slow lists. The handler fetches everything, then filters. Pass
$top,$filter, and$selectthrough to the API. Thereq.queryforwarding above does this for you.
Choosing between BTP and the other extension models
Use in-app extensibility for small field, form, and logic changes that belong to a standard business object. Use developer extensibility when the logic must run in the same transaction as the core, for example a validation during posting. Use side-by-side when the extension has its own users, its own data, a different release cycle, or needs to serve external parties. It is also the right place for work that would be too heavy for the core, such as analytics or machine learning.
Side-by-side is a poor fit when the logic must run synchronously inside a posting. A network call to BTP adds latency and a failure mode inside a core transaction.
Exercise
A company on Public Edition wants a supplier self-service portal. Suppliers outside the company log in, see their purchase orders, and confirm delivery dates. Which extension model fits, and how should the portal get purchase order data without polling constantly?
Show answer
Side-by-side on BTP, because the portal serves external users, has its own data and lifecycle, and Public Edition does not allow custom code in the core. The portal reads purchase orders through a released API with a communication arrangement. It subscribes to purchase order business events through the event broker, then calls the API with the key from each event to refresh the current state. The handler must be idempotent because events can be delivered more than once.
Exercise
Your team runs S/4HANA on-premise. A side-by-side app on BTP gets "host unreachable" when it calls the system. Name the component you need and two things to check in its configuration.
Show answer
The Cloud Connector, installed in the customer network. Check that the destination uses the virtual host defined in the Cloud Connector, and that the resource path of the API is added in the Cloud Connector access control list. You should also check that the Cloud Connector is connected to the correct BTP subaccount.