Beyond ABAPdesigned by@Tejoram97
Beyond ABAP / CAP / Remote Services & Integration – S/4HANA APIs, Destinations, Cloud SDK

Remote Services & Integration – S/4HANA APIs, Destinations, Cloud SDK

CAP · SAP BTP ·

Open the interactive lesson →
  1. Why remote services, and the Calesi idea
  2. Find and import the S/4HANA APIs
  3. Configure the remote services per profile
  4. Consumption views and associations to remote entities
  5. Mocking and the inner loop
  6. Querying remote services: delegation, mashups and federation
  7. Destinations and the path to an on-premise S/4HANA
  8. SAP Cloud SDK and CAP remote services
  9. Errors, timeouts and writes
  10. Interview questions

How the Order Approval Portal reads live sales orders and customers from SAP S/4HANA (CR9) – the CAP way. You import the released APIs as CDS models, define consumption views, query them with CQL as if they were local, run everything mocked on the laptop, and in production reach S/4HANA through the Destination and Connectivity services. The page also explains where the SAP Cloud SDK fits and how to handle errors, timeouts and writes. Events from S/4HANA are on page 10 (→ CAP › 10 · Messaging & Events); deployment of the bindings on page 08; trust, principal propagation and the Cloud Connector set-up in BTP Foundations › 03 and BTP Foundations › 04. Sources: capire ("CAP-level Service Integration", "Remote Services", "Inner Loop Development") and the SAP Help Portal.

Part 1 – Why remote services, and the Calesi idea

Requirements on this page

ID

Requirement

How this page solves it

CR9

Read live sales orders and customers from S/4HANA

Imported APIs API_SALES_ORDER_SRV and API_BUSINESS_PARTNER, consumption views, delegation, destinations

CR4 (support)

Managers approve with one click – but only if the order still exists and the amount has not changed

Live check against S/4HANA inside the approve action (Part 6)

CR10 (support)

Approval requests are created from S/4HANA events

Remote read of order details in the event handler – page 10

Why: the portal stores only what S/4HANA does not know – approval requests, notes and decisions (CR1). Sales orders and customers stay in S/4HANA, the system of record. Copying them by hand or writing raw HTTP clients for every call is slow to build and hard to test. CAP's answer is CAP-level service integration (capire calls it the *Calesi* pattern): a remote API becomes a CAP service that you query with the same CQL as your own tables. CAP translates the query into OData, handles connectivity, user propagation and resilience, and mocks the remote service automatically while you develop.

Order Approval Portal reading S/4HANA sales orders and customers through consumption views, the Destination and Connectivity services and the Cloud Connector

Calesi principle (capire)

Meaning in the portal

Remote services are proxied by CAP services

cds.connect.to('API_SALES_ORDER_SRV') returns a cds.RemoteService – everything is a CAP service

Consumed in protocol-agnostic ways

S4.run(SELECT.from(SalesOrders)) – no URL building, no $filter strings

Mocked out of the box

cds watch serves a mock of both APIs with CSV data – no S/4HANA needed

Varying implementations

Mock → sandbox → test system → production, same handler code

Extensible through event handlers

before / on / after handlers on the remote proxy (mapping, caching, logging)

  • ABAP view: this is the CAP counterpart of a service consumption model plus a custom entity in RAP (→ RAP section). The big difference: CAP gives you a working mock and the same query language for local and remote data.

Part 2 – Find and import the S/4HANA APIs

2.1 Pick a released API

Use only released APIs (A2X OData services) from SAP Business Accelerator Hub (api.sap.com) – they are stable across upgrades and fit the clean-core rules (→ Clean Core section). For the portal:

Need

API (OData V2)

Entity used

Sales order header: customer, amount, currency, status, delivery block

API_SALES_ORDER_SRV – Sales Order (A2X)

A_SalesOrder

Customer name for value help and display

API_BUSINESS_PARTNER – Business Partner (A2X)

A_Customer

  • OData V4 versions of many APIs exist (for example the Sales Order V4 service). The CAP code is the same; the kind and the service path differ – take the exact path from the Hub.
  • Download the EDMX: Hub → product (S/4HANA Cloud Public Edition or on-premise) → APIs → the API → *API Specification* → *OData EDMX*. Alternatively save …/$metadata from your own system, which also contains customer-specific extension fields.

2.2 Import

cds import ~/Downloads/API_SALES_ORDER_SRV.edmx --as cds
cds import ~/Downloads/API_BUSINESS_PARTNER.edmx --as cds
srv/external/
API_SALES_ORDER_SRV.cds        <- CDS model of the API (without --as cds: a .csn file)
API_SALES_ORDER_SRV.edmx       <- original copy, keep it under version control
API_BUSINESS_PARTNER.cds
API_BUSINESS_PARTNER.edmx
package.json  -> cds.requires.API_SALES_ORDER_SRV  = { kind: "odata-v2", model: "srv/external/..." }
-> cds.requires.API_BUSINESS_PARTNER = { kind: "odata-v2", model: "srv/external/..." }

Source

Import

OData V2 EDMX

cds import file.edmx → kind: odata-v2

OData V4 EDMX

cds import file.edmx → kind: odata

OpenAPI (REST)

cds import file.json – operations become functions and actions

AsyncAPI (events)

cds import of an AsyncAPI file – event declarations, used on page 10

RFC-enabled function modules

cds import with the plugin @sap/cds-rfc

SAP data products

cds import --data-product …

Another CAP application

The provider exports its API as an npm package; the consumer runs npm add – no EDMX at all

  • Reuse packages: when several projects consume the same S/4HANA APIs, import them once into a small npm package (capire's @capire/s4 sample does exactly this) and npm add it everywhere.

Common mistakes

  • Editing the generated .cds/.csn by hand – the next import overwrites it. Put your changes into consumption views and extend statements in your own files.
  • Importing a non-released (internal) OData service because it has more fields – it can change with any S/4HANA upgrade.

Part 3 – Configure the remote services per profile

The cds.requires entry tells CAP what the remote service is (kind and model) and, per profile, where it is. No URL, user or password belongs in the code or the repository.

{
"cds": {
"requires": {
"API_SALES_ORDER_SRV": {
"kind": "odata-v2",
"model": "srv/external/API_SALES_ORDER_SRV",
"csrf": true,
"csrfInBatch": true,
"[sandbox]": {
"credentials": {
"url": " https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_SALES_ORDER_SRV",
"headers": { "APIKey": "<from .env – never commit>" }
}
},
"[production]": {
"credentials": {
"destination": "S4HANA_SALES",
"path": "/sap/opu/odata/sap/API_SALES_ORDER_SRV",
"requestTimeout": 30000
}
}
},
"API_BUSINESS_PARTNER": {
"kind": "odata-v2",
"model": "srv/external/API_BUSINESS_PARTNER",
"[production]": {
"credentials": { "destination": "S4HANA_SALES", "path": "/sap/opu/odata/sap/API_BUSINESS_PARTNER" }
}
}
}
}
}

Setting

Meaning

No credentials (development)

CAP mocks the service (Part 5)

destination

Name of a destination in the BTP subaccount: URL, authentication, proxy type

path

Service root appended to the destination URL

url + headers

Direct URL – only for sandboxes and tests; keep keys in .env or a binding

csrf, csrfInBatch

Fetch a CSRF token before changing requests (normal for S/4HANA OData V2)

requestTimeout

Milliseconds to wait for the remote system (Node.js default 60 000)

  • The sandbox URL format above is an example – copy the exact sandbox URL and the API key header from the Hub's *Try Out* page.
  • Profiles: cds watch = development; cds watch --profile hybrid or sandbox for your own; deployed apps run production. Profiles are explained on → CAP › 08 · Databases & Deployment.

3.1 The same in CAP Java

# srv/pom.xml: dependency com.sap.cds:cds-feature-remote-odata (scope runtime)
# srv/src/main/resources/application.yaml
cds:
remote.services:
API_SALES_ORDER_SRV:
type: "odata-v2"
destination:
name: "S4HANA_SALES"
  • Java uses the same imported CDS model; the remote service name defaults to the YAML key. Java handlers and CQN: → CAP › 05 · CAP Java.

Part 4 – Consumption views and associations to remote entities

Why: A_SalesOrder has well over a hundred fields with S/4HANA names. A consumption view declares the few fields the portal needs, renames them into the portal's language and is the only thing the rest of the model uses. capire: *"Always use consumption views."*

// srv/external/s4.cds – consumption views on the imported APIs
using { API_SALES_ORDER_SRV as so } from './API_SALES_ORDER_SRV';
using { API_BUSINESS_PARTNER as bp } from './API_BUSINESS_PARTNER';
namespace sap.capire.orderapproval.s4;

entity SalesOrders as projection on so.A_SalesOrder {
key SalesOrder             as ID,
SoldToParty            as customer,
SalesOrganization      as salesOrg,
TotalNetAmount         as netAmount,
TransactionCurrency    as currency,
OverallSDProcessStatus as status,
DeliveryBlockReason    as deliveryBlock,
CreationDate           as createdOn
};

entity Customers as projection on bp.A_Customer {
key Customer     as ID,
CustomerName as name
};
// db/schema.cds – local entities reference the remote ones
using { sap.capire.orderapproval.s4 as s4 } from '../srv/external/s4';
namespace sap.capire.orderapproval;

entity ApprovalRequests : cuid, managed {
salesOrder : String(10);
customer   : String(10);
netAmount  : Decimal(15, 2);
currency   : String(5);
status     : String(1) enum { New = 'N'; Approved = 'A'; Rejected = 'R' } default 'N';
deadline   : Date;
reason     : String(255);
order      : Association to s4.SalesOrders on order.ID = salesOrder;   // unmanaged: key stays local
customerBP : Association to s4.Customers   on customerBP.ID = customer;
notes      : Composition of many Notes on notes.request = $self;
}
  • The full portal model (Notes, Decisions, aspects) is on → CAP › 02 · CDS Modeling. Here only the links to S/4HANA matter.
  • Use unmanaged associations (on …) to remote entities: the foreign key lives in your table. capire allows extending remote entities only with elements that need no change on the remote side – virtual or calculated elements and unmanaged associations (e.g. a back-link from SalesOrders to ApprovalRequests).
  • Serve the views through your services: RepService exposes Customers as a read-only value help (→ CAP › 06 · Fiori Elements & Draft for @Common.ValueList).
// srv/rep-service.cds (extract)
using { sap.capire.orderapproval as my } from '../db/schema';
using { sap.capire.orderapproval.s4 as s4 } from './external/s4';

service RepService @(path: '/odata/v4/rep') {
entity ApprovalRequests as projection on my.ApprovalRequests;
@readonly entity Customers   as projection on s4.Customers;
@readonly entity SalesOrders as projection on s4.SalesOrders;
}

Common mistakes

  • OData does not support every projection feature on remote entities – for example flattening fields from associations (airline.name as airline) works against CAP's own HCQL protocol but not against an S/4HANA OData service. Keep consumption views on OData APIs flat.
  • Two consumption views with the same name in different files – use your own namespace (sap.capire.orderapproval.s4) to avoid clashes with the imported namespace.

Part 5 – Mocking and the inner loop

Why: S/4HANA systems are shared, slow to get access to, and full of data you may not use for tests. CAP lets the UI and logic teams start on day one with mocks and move step by step to the real system – with unchanged handler code.

Four stages from mocked in-process to production with unchanged handler code

5.1 Stage 1 – mocked in-process

cds watch
# [cds] - mocking API_SALES_ORDER_SRV { at: [ '/odata/v4/api-sales-order-srv' ], ... }
# [cds] - mocking API_BUSINESS_PARTNER { ... }
  • Mock data: CSV files named after the remote entity, e.g. srv/external/data/API_SALES_ORDER_SRV-A_SalesOrder.csv and srv/external/data/API_BUSINESS_PARTNER-A_Customer.csv. Keep the order numbers consistent with your ApprovalRequests test data.
  • The mock shares the in-memory database with your own entities, so even joins work – which hides problems (see stage 2).

5.2 Stage 2 – mock in its own process

cds mock srv/external/API_SALES_ORDER_SRV.cds      # terminal 1 – a real HTTP server for the API
cds mock srv/external/API_BUSINESS_PARTNER.cds     # terminal 2
cds watch                                          # terminal 3 – log: connect to API_SALES_ORDER_SRV > odata
  • Now CAP sends real HTTP requests. Missing delegation handlers, joins across systems and N+1 calls show up here – exactly as they would in production. capire's term: *integration logic required*.
  • cds repl against the mock is a quick way to try queries: await RepService.read('Customers').limit(3) and watch the translated OData request in the mock's log.

5.3 Stage 3 – hybrid and sandbox

  • Sandbox: the Hub's sandbox gives read access to sample data with an API key (profile sandbox above). Good for checking field contents and paging.
  • Hybrid: cds bind binds the local app to real BTP service instances (for example the Destination service) and cds watch --profile hybrid uses them. Works for destinations with proxy type Internet. On-premise destinations need the Connectivity proxy, which is reachable only from apps running on BTP – test that path after deployment.

Interview tip

"How do you develop against S/4HANA without a system?" – three answers in order: CAP's automatic mock with CSV data, cds mock in a separate process to test real HTTP, then the Business Accelerator Hub sandbox or a hybrid binding. Mention that the handler code never changes.

Part 6 – Querying remote services: delegation, mashups and federation

CAP's uniform API works for local and remote services: srv.run(query) for data, srv.send(request) for anything HTTP-like, srv.emit / srv.on for events (page 10). capire's advice: prefer run for data, emit for decoupling, and use send only when you need full flexibility.

Delegation, mashup in the handler and federation compared

6.1 Delegation – the value help

// srv/rep-service.js
const cds = require('@sap/cds');

module.exports = class RepService extends cds.ApplicationService {
async init() {
const S4   = await cds.connect.to('API_SALES_ORDER_SRV');
const bupa = await cds.connect.to('API_BUSINESS_PARTNER');
const { Customers, SalesOrders } = this.entities;

// without these handlers CAP would look for local tables that do not exist
this.on('READ', Customers,   req => bupa.run(req.query));
this.on('READ', SalesOrders, req => S4.run(req.query));

return super.init();
}
};

CAP translates the incoming query on RepService.Customers through the consumption view down to A_Customer: $select, $filter, $top, $orderby are mapped to the remote names, and the result is mapped back. capire calls this automatic query translation.

6.2 Mashup – enrich a page of local results

// srv/manager-service.js – add customer names to the open requests without N+1 calls
this.after('READ', 'ApprovalRequests', async (requests) => {
const list = Array.isArray(requests) ? requests : [requests];
const ids  = [...new Set(list.map(r => r.customer).filter(Boolean))];
if (!ids.length) return;
const customers = await bupa.run(SELECT.from(Customers).columns('ID', 'name').where({ ID: { in: ids } }));
const byId = Object.fromEntries(customers.map(c => [c.ID, c.name]));
for (const r of list) r.customerName = byId[r.customer];   // virtual element in the CDS model
});
  • Navigations and expands across systems (where order.netAmount > 1000, $expand=order) cannot be pushed into one SQL statement. Without federation you split the query: read the remote IDs first, then query the local table with in, or fetch nested data per page – capire shows both patterns.

6.3 Live check inside an action (CR4)

// srv/manager-service.js – approve only if S/4HANA still has the same amount
this.before('approve', 'ApprovalRequests', async (req) => {
const request = await SELECT.one.from(req.subject);
const order   = await S4.run(SELECT.one.from(SalesOrders).where({ ID: request.salesOrder }));
if (!order) return req.reject(404, `Sales order ${request.salesOrder} no longer exists in S/4HANA`);
if (Number(order.netAmount) !== Number(request.netAmount))
return req.reject(409, 'Order amount changed in S/4HANA – please review again');
});
  • Actions, req.subject and req.reject are explained on → CAP › 04 · Custom Logic in Node.js.

6.4 Federation – keep a local copy

// db/replica.cds – turn the consumption view into a real table
using { sap.capire.orderapproval.s4 as s4 } from '../srv/external/s4';
annotate s4.Customers with @cds.persistence.table;
// delta replication (e.g. run as a scheduled task – page 10, Part 7)
const { Customers } = cds.entities('sap.capire.orderapproval.s4');
const fresh = await bupa.run(SELECT.from(Customers));   // or a delta by change date, if the API has one
if (fresh.length) await UPSERT(fresh).into(Customers);
  • Then lists can join, sort and filter on customer names in SQL, and the portal keeps working when S/4HANA is down. The price: eventual consistency and a copy of personal data (retention and deletion rules apply – → CAP › 12 · Testing, Plugins, Observability & Performance for audit logging).
  • capire's "CAP-level Data Federation" guide tags consumption views with @federated and lets a generic handler turn them into local replica tables; HANA virtual tables, synonyms and data products are listed there as further options.

Common mistakes

  • Remote call inside after('each') → one HTTP call per row (N+1). Always batch with in.
  • Defining a CDS view that joins a local table with a remote entity – the database cannot reach S/4HANA.
  • Replicating everything "to be safe" – replicate only the fields you join or sort on.

Part 7 – Destinations and the path to an on-premise S/4HANA

Why: in production the code names only a destination. Everything else – URL, authentication, network path – is configuration owned by the BTP subaccount administrator. This is how the same app can talk to S/4HANA Cloud, an on-premise system or (per tenant) the customer's own system (page 11).

Seven steps of one remote call from a CAP handler to on-premise S/4HANA

Destination property

On-premise S/4HANA

S/4HANA Cloud

Name / Type

S4HANA_SALES / HTTP

S4HANA_SALES / HTTP

URL

virtual host from the Cloud Connector, e.g. http://s4h-virtual:44300

https://my…-api.s4hana.cloud.sap

Proxy type

OnPremise

Internet

Authentication

PrincipalPropagation or BasicAuthentication (technical user)

OAuth2SAMLBearerAssertion / OAuth2 client credentials / basic (communication user) – depends on the communication arrangement

Additional properties

sap-client; Location ID if several Cloud Connectors

–

7.1 Principal propagation or technical user?

Principal propagation

Technical user

Who S/4HANA sees

The real portal user (MANAGER_42)

One communication / system user

Authorization

S/4HANA checks the user's own roles – region and sales org restrictions apply

The portal must restrict data itself (@restrict, → page 07)

Audit

Changes logged under the real user

Changes logged under the technical user

Effort

Trust BTP ↔ Cloud Connector ↔ S/4HANA, user mapping

Simple

Background jobs / events

Not possible – there is no user

Required (event handlers run privileged)

  • Many projects use both: principal propagation for user requests (S4HANA_SALES), a technical destination for event handlers and replication (S4HANA_SALES_TECH) – two cds.requires entries on the same imported model, each with its own credentials.destination.

7.2 Bindings

cds add xsuaa,destination,connectivity    # adds services to package.json and, with cds add mta, to mta.yaml
  • Deployed app bound to XSUAA/IAS (user token), Destination (lookup) and Connectivity (proxy for OnPremise). The MTA and Helm details are on → CAP › 08 · Databases & Deployment.

Part 8 – SAP Cloud SDK and CAP remote services

Why: "Do you use the SAP Cloud SDK?" is a frequent interview question. The precise answer: CAP remote services use the SAP Cloud SDK underneath for destinations, connectivity and resilience; you use the Cloud SDK directly only when CAP's query layer does not fit.

CAP remote service stack compared with direct SAP Cloud SDK usage

8.1 CAP Node.js

npm add @sap-cloud-sdk/http-client @sap-cloud-sdk/connectivity @sap-cloud-sdk/resilience
  • If @sap-cloud-sdk/http-client is installed, cds.RemoteService uses it by default – full Destination service support including OnPremise destinations through Connectivity.
  • Recent CAP releases also have a native fetch client (beta) that resolves destinations without the Cloud SDK, but only for proxy type Internet and a few authentication types (NoAuthentication, BasicAuthentication, OAuth2ClientCredentials). Setting cds.remote.native_fetch forces the choice. For the portal's on-premise case: install the Cloud SDK packages.

8.2 CAP Java

  • cds-feature-remote-odata builds on Cloud SDK destinations and propagates tenant and user from the request context. capire's "clear recommendation" is Remote Services over direct Cloud SDK use; for anything CQN cannot express, the Cloud SDK can be used natively in the same app.

8.3 When the SAP Cloud SDK directly is the right tool

Situation

Choice

Queries and CRUD on an OData API inside CAP

CAP remote service – CQL, mock, same code everywhere

A REST endpoint without a model (token endpoint, webhook)

srv.send({ method, path, data }) on a remote service, or Cloud SDK executeHttpRequest

Node.js or Java app without CAP (plain Express, Spring Boot)

SAP Cloud SDK: typed clients generated from EDMX/OpenAPI, destinations, resilience

Special OData handling (complex $batch, ETags per entity, deep inserts the API needs)

Cloud SDK typed client in one CAP module, called from a handler

Generative AI hub calls

SAP Cloud SDK for AI or the CAP AI plugin – → CAP › 13 · CAP and Generative AI

// srv.send for a call that has no CDS model behind it (works with mocks, sandbox and destinations alike)
const S4 = await cds.connect.to('API_SALES_ORDER_SRV');
const top5 = await S4.send({ method: 'GET', path: "A_SalesOrder?$top=5&$select=SalesOrder,TotalNetAmount" });

Part 9 – Errors, timeouts and writes

Why: a remote system is slower and less reliable than your own database. Interviews often ask "What happens if S/4HANA is down?" – answer with timeouts, clear errors, caching or federation, and queued writes.

9.1 Handle remote errors

this.on('READ', SalesOrders, async (req) => {
try {
return await S4.run(req.query);
} catch (e) {
// e.statusCode / e.reason carry the remote error details; log them, show a clean message to the user
cds.log('s4').error('S/4HANA read failed', e);
return req.error(502, 'Sales orders are temporarily unavailable – please try again later');
}
});
  • CAP Node.js wraps a failed remote call in an error with statusCode: 502 and the sanitised remote error (status, message) in e.reason. Never forward raw back-end messages with internal details to the UI.
  • requestTimeout per service (Part 3) prevents hanging requests; the Cloud SDK resilience package adds retries and circuit breakers where you configure them.

9.2 Writes to S/4HANA

Pattern

When

Direct S4.send('PATCH', …) / S4.run(UPDATE…)

The user must see the result immediately (e.g. a validation answer from S/4HANA)

Queued with cds.queued(S4)

The write must happen reliably after commit and the user does not need the answer – e.g. removing the delivery block after approval. → CAP › 10 · Messaging & Events, Part 7

Event instead of a call

Other systems decide themselves what to do (OrderApproved) – page 10

// update an S/4HANA sales order header: DeliveryBlockReason is an updatable field of A_SalesOrder
await S4.send('PATCH', `A_SalesOrder('${salesOrder}')`, { DeliveryBlockReason: '' });

Common mistakes

  • Calling S/4HANA directly inside a transaction that can still roll back – the remote change stays (phantom write). Queue it.
  • Forgetting csrf: true – S/4HANA OData V2 rejects changing requests with 403 "CSRF token validation failed".
  • Testing the on-premise path only on the laptop – the Connectivity proxy is reachable only from BTP.

Part 10 – Interview questions

Q1. How do you consume an S/4HANA OData API in CAP, step by step?

Find the released API on SAP Business Accelerator Hub, download the EDMX, cds import it (CDS model in srv/external, cds.requires entry with kind: odata-v2), write a consumption view with the needed fields, expose it in a service, add an on('READ') handler that delegates with remote.run(req.query), and configure a destination plus path in the [production] profile. In development CAP mocks it.

Q2. What is the Calesi pattern?

CAP-level service integration: remote services are represented as CAP services, consumed with the same protocol-agnostic APIs as local ones (run, send, emit, on), mocked out of the box, replaceable by other implementations and extensible with handlers – so developers stay at domain level.

Q3. Why define consumption views on imported APIs?

They declare exactly what you use, rename S/4HANA fields into your domain, isolate the rest of the model from API changes, reduce payloads, and are the basis for federation. Generated files stay untouched, so re-imports are safe.

Q4. Explain the mocking options.

In-process mock by cds watch with CSV data in the same in-memory database; cds mock <model> in a separate process so real HTTP is used and integration logic is tested; the Hub sandbox or a hybrid binding with cds bind for real data. Handler code is identical in all stages.

Q5. Delegation, mashup or federation – how do you decide?

Delegation for value helps and single records (always current). Mashup when enriching a page of local results with one batched remote call. Federation (local replica refreshed by events or a scheduled task) when you join, sort or filter on remote fields or need availability when S/4HANA is down. Never one remote call per row.

Q6. What is the role of the SAP Cloud SDK in a CAP app?

It is the HTTP and connectivity layer under CAP remote services: destination lookup, Connectivity proxy for on-premise, principal propagation, resilience. In Node.js CAP uses it when @sap-cloud-sdk/http-client is installed (a native fetch client exists for Internet destinations); in Java via cds-feature-remote-odata. Use it directly only for non-CAP apps or requests CQL cannot express.

Q7. Which BTP services does a CAP app need to call an on-premise S/4HANA?

XSUAA or IAS for the user token, the Destination service for URL and authentication, the Connectivity service as proxy, and a Cloud Connector in the customer network that exposes the virtual host and the OData path. Bind them with cds add xsuaa,destination,connectivity and the MTA.

Q8. Principal propagation or technical user?

Principal propagation when S/4HANA must check the real user's authorizations and log changes under that user; it needs trust and user mapping. A technical user for background work and event handlers, where no user exists; then the portal must enforce restrictions itself. Many apps use both.

Q9. Why does $expand from a local entity to a remote one not work automatically?

The database cannot join across systems, and CAP can push a query only to one target. You either replicate the remote data (federation), or split the query: read remote IDs or details in one batched call and merge in the handler.

Q10. Scenario: the manager list of 200 open requests takes 40 seconds since customer names were added. What do you check?

Most likely an N+1 pattern – one remote call per request in an after('each') handler. Fix by collecting customer IDs and reading them in one call with in, paging the list, or replicating customer names locally and joining in SQL. Check requestTimeout, and use telemetry to see the remote calls per request (page 12).

Q11. Scenario: everything works with cds watch, but after deployment every S/4HANA call fails with 503 or 404.

Locally the service was mocked or used an Internet destination. In BTP check: Connectivity service bound and the Cloud SDK packages installed (Node.js), destination name and proxy type OnPremise, Location ID, the Cloud Connector connected to this subaccount and exposing the virtual host and path /sap/opu/odata/sap/, and user mapping for principal propagation. Test with the destination check in the cockpit and the app logs.

🏠 Start Here · ◀ 08 · Deployment · 10 · Messaging ▶ · Sections: CORE ABAP | OOPS ABAP | ABAP on HANA | Clean Core | RAP | ABAP Points | SAP Fiori | SAPUI5 | Mobile Development (MDK) | BTP Foundations | BTP Development | CAP | SAP Build | ABAP on BTP | Integration Suite | SAP Business AI | SAP BASIS | Security | SAP SDLC

Functional: FICO ABAP | TRM ABAP | VIM | SAP BIS | SD ABAP | MM ABAP | PP ABAP | QM ABAP | PM ABAP | PS ABAP | EWM | TM ABAP | EHS ABAP | HR ABAP | BW | SAP MDG | SAP Analytics Cloud | SAP Ariba | SAP CX | SAP IBP