Consuming SAP APIs from CAP

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

A new application next to SAP S/4HANA rarely owns all of its data. The partner dashboard of Example Trading Co. (EX01) shows business partners, and the master record of a business partner lives in the SAP S/4HANA system, not in the dashboard. The SAP Cloud Application Programming Model (CAP) handles this with remote services: you give CAP the description of the foreign API, CAP turns it into a service you can query like a local one, and during development it can pretend to be that API, so you can build and test without an SAP system. This page follows that path with a real file: it imports the OData definition of API_BUSINESS_PARTNER, adds a small interface of your own on top, reads partners from a mocked service in the same process and in a separate process, and shows the configuration that points the same code at a real system through a destination. It is written for CAP Node.js 10.2 (@sap/cds 10.2.2 with @sap/cds-dk 10.2.1, Node.js 22.12 or newer) and CAP Java 5.2 (Java 21 or newer, Java 25 recommended). The local steps run on any developer machine; the steps that reach a real system run on SAP BTP, on Cloud Foundry or on Kyma, and need an SAP BTP account, so they are described and not run. SAP BTP is still the documented name; SAP now presents SAP BTP capabilities as part of SAP Business AI Platform.

Before you read

Key terms

  • Remote service: a service that runs somewhere else, which CAP lets your code call as if it were a local service.

  • EDMX: the XML file that describes an OData service (its entities, properties and associations), which cds import reads.

  • Mocking: letting CAP serve a stand-in for a remote service from sample data, so development needs no real system.

  • Projection: a CDS entity defined as a selection of fields of another entity, with optional new names.

  • OData: the web protocol in which SAP S/4HANA publishes its business APIs.

  • Destination: a named entry on SAP BTP that holds the address and sign-in details of a remote system.

The idea in one picture

CAP’s guide to consuming services describes the approach this way: as everything in CAP is a service, remote services are modeled the same way as local ones, using CDS. Your code calls cds.connect.to with the name of the service and gets an object it can run queries against. Where the call really goes depends on the environment, and your code does not change.

flowchart LR A["curl or browser"] --> B["PartnerDashboard.Partners with a READ handler"] B --> C["API_BUSINESS_PARTNER: remote service proxy"] C -- "development: mock in the same process" --> D["Mock with sample data in the same database"] C -- "development: mock in a separate process" --> E["cds mock process answering OData"] C -- "production: credentials with a destination" --> F["Destination EX01-S4HANA"] F --> G[("SAP S/4HANA: API_BUSINESS_PARTNER")]

SAP marks the Consuming Services guide as outdated and replaced by the CAP-level Service Integration guide, and keeps it for archival purposes for a limited time. This page uses the newer guide for the concepts and the archived one only where the newer one does not say the same thing, and it says so where it does. Every command and output below was run on 2026-11-13 in a scratch project built from the pinned lab versions; only the destination part is configuration that cannot be run without an SAP BTP account.

Getting the API definition

CAP needs the definition of a remote API in the project, because the definition is what lets it check queries and mock the service. SAP calls such a definition an external service API. For SAP APIs the usual source is the SAP Business Accelerator Hub. The newer CAP guide describes the way for the business partner API: open the hub in a browser, go to SAP S/4HANA Cloud Public Edition, then APIs, then OData V2, open Business Partner (A2X), switch to the API Specification tab and use the download icon next to OData EDMX. The archived guide adds that EDMX is the format to use when it is offered, and that EDMX files for OData V2 and V4 are supported. The hub’s downloads need a sign-in, and no account is used for this page, so the hub steps are described from the CAP guides and were not run here.

For a service that another CAP application provides, the archived guide recommends EDMX as the exchange format as well and shows cds compile srv -s OrdersService -2 edmx > OrdersService.edmx to produce it. It warns against copying the other project’s CDS files, because the effective API depends on the protocol, includes cannot be resolved and CAP would create database tables for entities that belong to the other service.

This page needs a real EDMX file that anyone can fetch. The public GitHub repository capire/s4, a CAP sample that SAP publishes under the Apache License 2.0, holds the business partner definition as srv/external/API_BUSINESS_PARTNER.edmx. Its readme says it is only a sample, not meant for production use. The file was downloaded over plain HTTP from raw.githubusercontent.com into a separate folder (695,017 bytes, SHA-256 810008e1...faf77) and treated as data: it was only read by cds import, never executed. In a real project you download the file for your own SAP S/4HANA release from the hub.

Source: CAP-Level Service Integration (section Importing APIs), Consuming Services (archived CAP guide) (section Import External APIs) and capire/s4 on GitHub

Importing it with cds import

The project of this page is a copy of the CAP lab with its model removed and the name partner-dashboard: package.json with @sap/cds 10.2.2 and the development dependencies of the lab, installed with npm ci. The scratch folder is g9-122. The import command takes the file and, with --as cds, writes a human-readable CDS file next to a copy of the EDMX.

$ npx cds import ../dl/API_BUSINESS_PARTNER.edmx --as cds
[cds] - updated ./package.json

[cds] - imported API to srv/external/API_BUSINESS_PARTNER
> use it in your CDS models through the likes of:

using { API_BUSINESS_PARTNER as external } from './external/API_BUSINESS_PARTNER';

Source: output of cds import with @sap/cds-dk 10.2.1; the options are those of cds import --help and of Consuming Services (archived CAP guide)

Without further options cds import copies the source into srv/external, writes the converted model beside it and adds an entry for the service to package.json, as cds import --help says. This is what it did here.

  • srv/external/API_BUSINESS_PARTNER.edmx, an unchanged copy of the input (695,017 bytes).

  • srv/external/API_BUSINESS_PARTNER.cds, the converted model (179,709 bytes, 4,699 lines, 65 entities). Its first line is a checksum comment, and every entity carries @cds.external : true and @cds.persistence.skip : true: the project never creates database tables for them unless they are mocked.

  • A new block in package.json, shown below. It records kind odata-v2, the kind CAP assigns to an imported OData V2 file, and the model path. The archived guide’s feature overview marks OData V2 as deprecated and says to use OData V4 when calling another CAP service. The archived guide lists the mapping of imported formats to kinds: OData V2 to odata-v2, OData V4 to odata, OpenAPI to rest and AsyncAPI to odata.

"cds": {
  "requires": {
    "API_BUSINESS_PARTNER": {
      "kind": "odata-v2",
      "model": "srv/external/API_BUSINESS_PARTNER"
    }
  }
}

Source: diff of package.json before and after the import above; the entry format is the one in Consuming Services (archived CAP guide)

The import also added three SAP Cloud SDK packages (@sap-cloud-sdk/connectivity, @sap-cloud-sdk/http-client and @sap-cloud-sdk/resilience, each with the version range ^4) to dependencies. The mocked runs below did not need them and they were not installed here; a project that calls a real system installs them with its other dependencies.

The imported entity A_BusinessPartner has 84 elements (58 properties and 26 associations); a selection is shown below (shortened). Note the { } at the end of each association: CAP marks the associations of an imported service with an empty key list, because the EDMX does not say how to look up the related rows.

@cds.external : true
@cds.persistence.skip : true
@sap.deletable : 'false'
@sap.content.version : '1'
@sap.label : 'Business Partner'
entity A_BusinessPartner {
  @sap.label : 'Business Partner'
  @sap.quickinfo : 'Business Partner Number'
  key BusinessPartner : String(10) not null;
  Customer : String(10);
  Supplier : String(10);
  BusinessPartnerCategory : String(1);
  BusinessPartnerFullName : String(81);
  // ... more elements ...
  to_BusinessPartnerAddress : Association to many A_BusinessPartnerAddress {  };
  // ... more associations ...
};

Source: lines of srv/external/API_BUSINESS_PARTNER.cds generated by the import above (most annotations and elements omitted); Business Partner (A2X) - OData API (Public Edition 2608) for the entity and its navigation properties

The archived guide lists known limits of the import: not all features of OData, OpenAPI or AsyncAPI are supported, which may make the CDS compiler reject an imported model or render a different API, and cyclic type references and inheritance are named as known limitations. It also says that a modified imported file is protected by the checksum, so a second cds import --as cds refuses to overwrite it unless you pass --force.

Sample data for the mock

A mocked service has no real system behind it, so you give it rows. The archived guide says the CSV file goes into srv/external/data, and the first line of the server log below confirms the place. The file is named after the service and the entity, here API_BUSINESS_PARTNER.A_BusinessPartner.csv. For this page it is the file that capire/s4 ships next to its EDMX: 728 partner rows with five columns, separated by semicolons. This is the start of it.

BusinessPartner;PersonFullName;BusinessPartnerCategory;LastChangeDate;LastChangeTime
000001;Mrs. Theresia Buchholm;1;2024-01-19;21:48:32
000002;Mr. Johannes Buchholm;1;2024-01-08;11:22:01
000003;Mr. James Buchholm;1;2022-11-04;15:27:46

Source: first lines of srv/external/data/API_BUSINESS_PARTNER.A_BusinessPartner.csv, downloaded from capire/s4; the folder is the one named in Consuming Services (archived CAP guide) (section Add Mock Data)

The rows are sample people from the capire/s4 repository and have nothing to do with EX01’s real partners. A project that follows the real API uses the property names of the real entity, which is why the columns above are the EDMX names BusinessPartner, PersonFullName and so on.

Your own interface on top

The archived guide recommends that you do not use the imported entities directly. It is best practice to define your own interface to the external service, with only the fields you need, in a projection in your namespace, so your code stays independent of the remote service’s details and requests only what it requires. The newer guide calls such projections consumption views and says always to use them. The model below is a teaching model defined by this page. It is the whole of srv/partner-service.cds: one service for the dashboard, with one read-only entity Partners that renames three elements of A_BusinessPartner.

using { API_BUSINESS_PARTNER as bupa } from './external/API_BUSINESS_PARTNER';

service PartnerDashboard {
  @readonly entity Partners as projection on bupa.A_BusinessPartner {
    key BusinessPartner as ID,
    PersonFullName      as name,
    BusinessPartnerCategory as category
  };
}

Source: shaped after the projection examples in Consuming Services (archived CAP guide) (section Model Projections); the file ran as shown below

The projection sits on an entity that has no table, so a request for Partners has to be forwarded to the remote service. The archived guide says to write a handler that delegates the query. This is srv/partner-service.js, the whole file. It follows the lab’s ES module style and the cds.ApplicationService class of the newer guide: it connects to the remote service by its name, and for each read of Partners it hands the incoming query to the remote service unchanged.

import cds from '@sap/cds'

export default class PartnerDashboard extends cds.ApplicationService {
  async init() {
    const bupa = await cds.connect.to('API_BUSINESS_PARTNER')
    this.on('READ', 'Partners', req => bupa.run(req.query))
    return super.init()
  }
}

Source: Consuming Services (archived CAP guide) (section Expose Remote Services, which uses bupa.run(req.query) in a CommonJS handler) and CAP-Level Service Integration (section Connecting to Remote Services)

cds.connect.to is, in the newer guide’s words, the single common way to address service instances: for a local service it returns the local provider, and for a remote service it returns a remote proxy that translates local requests into protocol-specific ones. The new guide says to stay at CAP level with srv.run(<query>) and CQL for data reads, and to retreat to srv.send(<request>) only when needed. The incoming query req.query still names Partners and the renamed elements. CAP resolves the projection and maps the names to the remote ones before the call, as the next runs show.

First run: the mock in the same process

When you start the project with cds watch, CAP mocks the imported external service in the same process, with its data in the same in-memory database as your own. A request for Partners worked in this run even without the handler of the previous section, because the mock’s table sits in the same database. PORT=4122 sets the port used in this run. The output is shortened: the banner is removed.

$ PORT=4122 npx cds watch
[cds] - loaded model from 2 file(s):

  srv/partner-service.cds
  srv/external/API_BUSINESS_PARTNER.cds

[cds] - using bindings from: { registry: '~/.cds/services' }
[cds] - connect to db > sqlite { url: ':memory:' }
  > init from srv/external/data/API_BUSINESS_PARTNER.A_BusinessPartner.csv
/> successfully deployed to in-memory database.

[cds] - using auth strategy { kind: 'mocked' }
[cds] - serving PartnerDashboard {
  at: [ '/odata/v4/partner-dashboard' ],
  decl: 'srv/partner-service.cds:3',
  impl: 'srv/partner-service.js'
}
[cds] - mocking API_BUSINESS_PARTNER {
  at: [ '/odata/v4/api-business-partner' ],
  decl: 'srv/external/API_BUSINESS_PARTNER.cds:6'
}
[cds] - server listening on { url: 'http://localhost:4122' }
[cds] - server v10.2.2 launched in 251 ms

Source: output of cds watch in the scratch project; the line mocking API_BUSINESS_PARTNER is the one the guides describe

Two services are served: your PartnerDashboard and, because it is mocked, the foreign API_BUSINESS_PARTNER, which is served as OData V4 although the imported file is OData V2. The archived guide says the Node.js mock supports only OData V4. A request to the dashboard returns the partners whose name contains Astrid, through the renamed elements.

$ curl -s 'http://localhost:4122/odata/v4/partner-dashboard/Partners?$top=2&$select=ID,name&$filter=contains(name,%27Astrid%27)'
{"@odata.context":"$metadata#Partners","value":[{"ID":"000037","name":"Mrs. Astrid Gutenberg"},{"ID":"000087","name":"Mrs. Astrid Martin"}]}

$ curl -s 'http://localhost:4122/odata/v4/partner-dashboard/Partners/$count'
728

Source: real responses of the running mocked project; the OData query options are those of OData Version 4.0 URL Conventions

The log line for this request, [odata] - GET /odata/v4/partner-dashboard/Partners { '$top': '2', '$select': 'ID,name', '$filter': "contains(name,'Astrid')" }, shows only the incoming call: in this mode the "remote call" is an in-process query on the same database, so nothing travels over HTTP. This is the fast inner loop of the newer guide, where the services are mocked in process with a shared in-memory database.

Second run: the mock in a separate process

The in-process mock does not behave like a real external service: the communication is in-process and does not use HTTP or OData. For more realistic testing, the archived guide starts the mocked service in its own process with cds mock, and cds watch in the same project then finds it. cds mock --help says the command is a shortcut for cds serve --mocked <service> --in-memory? --port 0, so the mock takes a free port. The mock registers itself in the folder ~/.cds/services, which cds watch reads (the line using bindings from above). The two programs run in two terminals, shown here as one log each.

$ npx cds mock API_BUSINESS_PARTNER
...
[cds] - mocking API_BUSINESS_PARTNER {
  at: [ '/odata/v4/api-business-partner' ],
  decl: 'srv/external/API_BUSINESS_PARTNER.cds:6'
}
[cds] - server listening on { url: 'http://localhost:49310' }
[cds] - server v10.2.2 launched in 240 ms
$ PORT=4122 npx cds watch
...
[cds] - using bindings from: { registry: '~/.cds/services' }
[cds] - connect to db > sqlite { url: ':memory:' }
/> successfully deployed to in-memory database.

[cds] - connect to API_BUSINESS_PARTNER > odata { url: 'http://localhost:49310/odata/v4/api-business-partner' }
[cds] - using auth strategy { kind: 'mocked' }
[cds] - serving PartnerDashboard {
  at: [ '/odata/v4/partner-dashboard' ],
  decl: 'srv/partner-service.cds:3',
  impl: 'srv/partner-service.js'
}

Source: output of cds mock and cds watch in the scratch project (shortened where three dots stand); behavior as described in Consuming Services (archived CAP guide) (section Mock Remote Service as OData Service)

Now cds watch no longer mocks the service: it prints connect to API_BUSINESS_PARTNER > odata with the URL of the other process, the same wording as the newer guide shows. A request to the dashboard goes through your handler to that process.

$ curl -s 'http://localhost:4122/odata/v4/partner-dashboard/Partners?$top=3&$select=ID,name'
{"@odata.context":"$metadata#Partners","value":[{"ID":"000001","name":"Mrs. Theresia Buchholm"},{"ID":"000002","name":"Mr. Johannes Buchholm"},{"ID":"000003","name":"Mr. James Buchholm"}]}

This is the log of the mock process for that request.

[odata] - GET /odata/v4/api-business-partner/A_BusinessPartner { '$select': 'BusinessPartner,PersonFullName', '$top': '3' }

Source: responses and logs of the two processes of the same run

The last line is the proof of the translation. The dashboard asked for ID,name; the mock received a real OData call that asks for BusinessPartner,PersonFullName. CAP mapped the names of your projection back to the names of the remote entity before sending, and it mapped the answer forward to ID and name. The call that this mock received is the call a real system would receive, apart from the path and the sign-in.

Reading from the command line

The cds repl command starts the project in an interactive shell and puts every service in the global context under its name. The newer guide uses it to try out remote services. The two reads below were typed into cds repl ./ while cds mock API_BUSINESS_PARTNER ran in the same terminal session (an input script, so the prompts appear as >). read is the short form of run with a SELECT, and the tagged template makes the contains condition.

await API_BUSINESS_PARTNER.read`BusinessPartner, PersonFullName`.from`A_BusinessPartner`.limit(3)
await API_BUSINESS_PARTNER.read`BusinessPartner, PersonFullName`.from`A_BusinessPartner`.where`contains(PersonFullName,${'Astrid'})`.limit(2)
> [
  { BusinessPartner: '000001', PersonFullName: 'Mrs. Theresia Buchholm' },
  { BusinessPartner: '000002', PersonFullName: 'Mr. Johannes Buchholm' },
  { BusinessPartner: '000003', PersonFullName: 'Mr. James Buchholm' }
]
> [
  { BusinessPartner: '000037', PersonFullName: 'Mrs. Astrid Gutenberg' },
  { BusinessPartner: '000087', PersonFullName: 'Mrs. Astrid Martin' }
]

Source: output of cds repl in the scratch project, reformatted only in line breaks of the objects (the values are unchanged); shape of the calls from CAP-Level Service Integration (section Testing with cds repl)

The mock process logged the matching OData calls, with $select for the two properties, $top and, for the second call, $filter with contains(PersonFullName,'Astrid'). The condition has to be written as the function contains, which OData understands: a first attempt in a small script with a like condition was sent as $filter=PersonFullName like 'Mrs. Astrid%' and the mock answered with HTTP status 400 and the message that it expected one of (, eq, ge, gt, in, le, lt or ne.

Going to a real system

The code of this page does not change for production. What changes is the credentials of the remote service, which tell it where to send its calls. The usual form names a destination and a path that is appended to the destination’s URL, wrapped in a [production] profile because you do not want it for local testing; for a service listed on the hub, the path is in the linked service documentation. The block below extends the generated entry with the destination name EX01-S4HANA that the page on destinations defines, and the path that the archived guide shows for this API. The spelling of the path (sap in lower case or upper case) differs between SAP help pages, so take it from the service catalog of your own system.

"cds": {
  "requires": {
    "API_BUSINESS_PARTNER": {
      "kind": "odata-v2",
      "model": "srv/external/API_BUSINESS_PARTNER",
      "[production]": {
        "credentials": {
          "destination": "EX01-S4HANA",
          "path": "/sap/opu/odata/sap/API_BUSINESS_PARTNER"
        }
      }
    }
  }
}

Source: Consuming Services (archived CAP guide) (section Using Destinations)

cds env get prints the merged configuration, so the effect of the profile can be checked without any SAP BTP account. This is its real output for the project, without and with the production profile. The second run shows the credentials block that the profile adds.

$ npx cds env get requires.API_BUSINESS_PARTNER
{
  "impl": "@sap/cds/srv/remote-service.js",
  "external": true,
  "kind": "odata-v2",
  "model": "srv/external/API_BUSINESS_PARTNER"
}

$ npx cds env get requires.API_BUSINESS_PARTNER --profile production
{
  "impl": "@sap/cds/srv/remote-service.js",
  "external": true,
  "kind": "odata-v2",
  "model": "srv/external/API_BUSINESS_PARTNER",
  "credentials": {
    "destination": "EX01-S4HANA",
    "path": "/sap/opu/odata/sap/API_BUSINESS_PARTNER"
  }
}

Source: output of cds env get with @sap/cds-dk 10.2.1 in the scratch project

The call to the destination requires an SAP BTP account; not run here. It needs a destination EX01-S4HANA in the subaccount, bindings to the XSUAA and Destination services (and to the Connectivity service for an on-premise system), and a deployment on Cloud Foundry or Kyma. The page Connectivity, Destinations and Cloud Connector explains what a destination holds, how the Cloud Connector maps a virtual host to the internal one, how a multitenant application chooses between the provider and the subscriber destination, and what cds add xsuaa,destination,connectivity does; none of it is repeated here. That page also notes that this archived guide has been replaced by the CAP-level service integration guide. The destination mechanism it describes is the same one used here.

Transient access or a copy

The reads above fetch the data live from the remote system on every request. The archived guide compares this transient access with replication: live access gives current data and can evaluate the user’s permissions in the remote system, but its performance depends on the remote system and it cannot filter on local and remote fields at the same time; replication is fast and allows such filters, but data is outdated until it is replicated. The newer guide takes the second path for data that must be in close access to be joined with local data, and calls it data federation: you annotate the consumption view with @federated and CAP replicates it, and for value helps and similar cases it still delegates a read to the remote service, exactly as the handler above does. For a partner dashboard that only lists partners, transient access is the simpler start. When the dashboard must sort or filter partners together with its own tables, read the CAP-level data federation guide.

Source: Consuming Services (archived CAP guide) (section Limitations and Feature Matrix) and CAP-Level Service Integration (sections Data Federation and Delegation)

The same in CAP Java

CAP Java uses the same imported model and the same projections. The differences are in configuration and code. CAP Java needs the remote OData feature as a runtime dependency, and the service is declared in Spring Boot’s application.yaml. The listings follow the archived guide, are not CAP Node.js output, and were not run here, because this page built no Java project.

<dependency>
  <groupId>com.sap.cds</groupId>
  <artifactId>cds-feature-remote-odata</artifactId>
  <scope>runtime</scope>
</dependency>
spring:
  config.activate.on-profile: cloud
cds:
  remote.services:
    API_BUSINESS_PARTNER:
      type: "odata-v2"

Source: Consuming Services (archived CAP guide) (section Import API Definition, Java tab)

The service is then injected by its name and queried with the CAP Java query API, as the guide shows.

@Autowired
@Qualifier(ApiBusinessPartner_.CDS_NAME)
CqnService bupa;

CqnSelect select = Select.from(ABusinessPartner_.class).limit(100);
List<ABusinessPartner> businessPartner = bupa.run(select).listOf(ABusinessPartner.class);

Source: Consuming Services (archived CAP guide) (section Execute Queries with Java); not run here

For a destination, the same guide replaces type and adds destination with a name and, for this API, http with a suffix; the listing is on the page about destinations, and it needs an SAP BTP account. The archived guide also describes a mocked profile for Java in which the application serves the mock over HTTP itself.

What can go wrong

Each row below was seen in a real run on this page, except where the last column names the guide.

What you see Why What to do

Entity "PartnerDashboard.Partners" is annotated with "@cds.persistence.skip" and cannot be served generically. with status 501, when the mock runs in a separate process and the project has no handler

The projection has no table, and with the mock outside, nothing in the dashboard’s own database holds the rows

Add the handler that runs req.query on the remote service. With the mock in the same process the read worked without a handler in this run, because the mock keeps its data in the same database; the archived guide still asks for a handler that delegates the query.

Error: No credentials configured for "API_BUSINESS_PARTNER". at start

The project was started with plain cds serve, which does not mock services and did not use a registered mock in this run, and the entry has no credentials. A plain Node script that calls cds.connect.to fails the same way

Use cds watch, or cds serve --with-mocks --in-memory?, which started and answered correctly in this run, or add credentials for a real service.

cds watch mocks the service in its own process although cds mock is running

cds watch connects only to mock servers listed in ~/.cds/services whose process it can see. In this run, a mock started from a different terminal session was not used, and its registry file was deleted as stale. The installed @sap/cds 10.2.2 compares the registered process id with the output of ps -o pid=

Start cds mock and cds watch in terminals of the same user session, as the guides show.

HTTP status 400 with Parsing URL failed ... Expected "(", "eq", "ge" ...

A like condition was sent to the remote service as $filter text that OData does not know

Write the condition as contains(...), startswith(...) or another OData function, or filter in your handler.

HTTP status 404 for a request that names an association foreign key

From the archived guide: cds import adds an empty key list to each association; without it CAP invents foreign keys that the real service lacks

Import the definition again with cds import.

Source: logs and responses of the runs above; the last row is from Consuming Services (archived CAP guide) (section Expose Remote Services)

Summary

  • A remote service is modeled in CDS like a local one: cds import turns an EDMX file (from the SAP Business Accelerator Hub, or from a CAP service via cds compile ... -2 edmx) into srv/external/<name>.cds, copies the EDMX there and adds a cds.requires entry with the kind odata-v2 for OData V2.

  • The hub download needs a sign-in; this page imported the public capire/s4 copy of API_BUSINESS_PARTNER instead and ran every local step for real.

  • Sample rows in srv/external/data let cds watch mock the service in process, and cds mock serves it as OData in a separate process that cds watch finds in ~/.cds/services.

  • Your code defines its own projection (PartnerDashboard.Partners here), connects with cds.connect.to and delegates the query with run(req.query); CAP renames elements in both directions, which the mock’s log shows as $select=BusinessPartner,PersonFullName.

  • For a real system the entry gets credentials with a destination name and a path in a [production] profile; the destination itself and everything on SAP BTP is described on the destinations page and was not run here.

  • The archived consuming-services guide is replaced by the CAP-level service integration guide, which adds consumption views, packaged APIs and data federation.

Try it

To do this by hand, follow the guide Consume an SAP API Specification in CAP: it consumes an SAP API specification in CAP against mocked data.