Add two samples that reach an SAP system: OData and RFC - #1
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 serviceAPI_BUSINESS_PARTNERwithcds.connect.toandcds.ql, which CAP's remote service sends as OData V2 ($select,$filterwithsubstringof,$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. CallsBAPI_USER_GETLIST(the search pattern goes in as a ranges table) and, on a row press,BAPI_USER_GET_DETAILthrough@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 fromRETURN.node-rfc, which the classic Node.js examples use, is archived by SAP;@sap/cds-rfcis its place in a CAP project. The README names both connectors for it: SAP's@sap-rfc/node-rfc-library, and the SDK-freeopen-rfc(beta) through an npm override.Mocked and remote
Both samples run as they are. While no credentials are configured,
cds watchmocks the two systems: CSV rows for the OData service,srv/external/SAP_RFC.jsfor the BAPIs. Credentials in a.envfile 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_RFCneeds"external": trueincds.requiresfor that switch. Therfckind does not declare itself external, so without the flag CAP keeps using the mock next to the model even when credentials are configured.Repository
srv/apps/holds one file per sample.srv/external/holds the models (in the shapecds importwrites, trimmed to what the samples use) and the mocks.AGENTS.mdandCLAUDE.mddocument naming (Z2UI5_CL_CAPS_APP_<nnn>), the mocked-and-remote rule, and how to add a sample..github/workflows/test.ymlrunsnpm run lintandnpm test.Test plan
npm run lintnpm test: 5 tests.test/samples.test.mjsdrives both samples over the wire against the mocks.test/remote.test.mjsconfigures 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.npm test. The render gate was also run once by hand, headless in Chromium, with no findings.open-rfcthrough the npm override:@sap/cds-rfcloads it, and the sample reaches the network with it (checked against a closed port).srv/external/SAP_RFC.cdsis hand-trimmed, and some DDIC lengths (e.g.BAPIUSSRGE-LOW) should be checked withcds import --from rfcagainst a real system.🤖 Generated with Claude Code
https://claude.ai/code/session_01LHXmTxE1Si2KM9RpCZBUbG
Generated by Claude Code