Skip to content

Add two samples that reach an SAP system: OData and RFC - #1

Merged
oblomov-dev merged 1 commit into
mainfrom
claude/jolly-euler-6gbbjj
Sep 29, 2026
Merged

oblomov-dev merged 1 commit into
mainfrom
claude/jolly-euler-6gbbjj

Conversation

@oblomov-dev

Copy link
Copy Markdown
Member

The first content of cap2UI5/samples-stack: two cap2UI5 apps that reach another system, built the way CAP builds such calls. The point they make is that a cap2UI5 app needs nothing of its own for this — it is a CAP handler, and CAP's remote services do it.

The samples

  • Z2UI5_CL_CAPS_APP_001 — OData. Reads business partners from S/4HANA's OData service API_BUSINESS_PARTNER with cds.connect.to and cds.ql, which CAP's remote service sends as OData V2 ($select, $filter with substringof, $top, $inlinecount). The list filters by name and category, and a row press loads that partner's addresses in a second request.
  • Z2UI5_CL_CAPS_APP_002 — RFC. Calls BAPI_USER_GETLIST (the search pattern goes in as a ranges table) and, on a row press, BAPI_USER_GET_DETAIL through @sap/cds-rfc: await sap.BAPI_USER_GET_DETAIL({ USERNAME }). Between them they pass single values, structures and tables in both directions, and errors are read from RETURN. node-rfc, which the classic Node.js examples use, is archived by SAP; @sap/cds-rfc is its place in a CAP project. The README names both connectors for it: SAP's @sap-rfc/node-rfc-library, and the SDK-free open-rfc (beta) through an npm override.

Mocked and remote

Both samples run as they are. While no credentials are configured, cds watch mocks the two systems: CSV rows for the OData service, srv/external/SAP_RFC.js for the BAPIs. Credentials in a .env file or a BTP destination switch them to the real systems without a code change. The README covers the Business Accelerator Hub sandbox, an own system and SAP BTP.

SAP_RFC needs "external": true in cds.requires for that switch. The rfc kind does not declare itself external, so without the flag CAP keeps using the mock next to the model even when credentials are configured.

Repository

  • App files: srv/apps/ holds one file per sample.
  • Remote systems: srv/external/ holds the models (in the shape cds import writes, trimmed to what the samples use) and the mocks.
  • Guidance: AGENTS.md and CLAUDE.md document naming (Z2UI5_CL_CAPS_APP_<nnn>), the mocked-and-remote rule, and how to add a sample.
  • CI: .github/workflows/test.yml runs npm run lint and npm test.

Test plan

  • npm run lint
  • npm test: 5 tests.
    • test/samples.test.mjs drives both samples over the wire against the mocks.
    • test/remote.test.mjs configures credentials and fakes only the far ends: an OData V2 server, and a stand-in for the RFC connector below @sap/cds-rfc. It asserts what the systems would receive: the exact OData URLs including quote escaping, and the RFC parameters sorted into import and table.
  • Every view and popup passes the abap2UI5 linter's property gate at UI5 1.71, inside npm test. The render gate was also run once by hand, headless in Chromium, with no findings.
  • open-rfc through the npm override: @sap/cds-rfc loads it, and the sample reaches the network with it (checked against a closed port).
  • Against a real SAP system: not possible here. srv/external/SAP_RFC.cds is hand-trimmed, and some DDIC lengths (e.g. BAPIUSSRGE-LOW) should be checked with cds import --from rfc against a real system.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LHXmTxE1Si2KM9RpCZBUbG


Generated by Claude Code

cap2UI5/samples-stack was empty. It starts with the two integrations an
SAP developer asks for first, both built the way CAP builds them, so
the samples show that a cap2UI5 app needs nothing of its own to reach
another system - it is a CAP handler, and CAP's remote services do it:

- Z2UI5_CL_CAPS_APP_001 reads business partners from S/4HANA's OData
  service API_BUSINESS_PARTNER with cds.ql, which CAP's remote service
  sends as OData V2 ($select, $filter, $top, $inlinecount).
- Z2UI5_CL_CAPS_APP_002 calls BAPI_USER_GETLIST and
  BAPI_USER_GET_DETAIL over RFC with @sap/cds-rfc: single values,
  structures and tables in both directions, errors read from RETURN.
  node-rfc, which the classic Node.js examples use, is archived by SAP;
  @sap/cds-rfc is its place in a CAP project.

Both run as they are: cds watch mocks the two systems while no
credentials are configured (CSV rows for the OData service,
srv/external/SAP_RFC.js for the BAPIs), and credentials alone switch
them to the real systems - the README says how, for the Business
Accelerator Hub sandbox, an own system and SAP BTP. SAP_RFC needs
"external": true in cds.requires for that: the rfc kind does not
declare itself external, and without the flag CAP keeps the mock next
to the model even with credentials configured.

The tests drive both samples over the wire twice: against the mocks,
and with credentials against faked far ends - an OData V2 server and a
stand-in for the RFC connector below @sap/cds-rfc - asserting what the
systems would receive. Every view the samples display passes the
abap2UI5 linter's property gate at UI5 1.71.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LHXmTxE1Si2KM9RpCZBUbG
@oblomov-dev
oblomov-dev merged commit ad37320 into main Sep 29, 2026
1 check passed
@oblomov-dev
oblomov-dev deleted the claude/jolly-euler-6gbbjj branch September 29, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants