@raptortwentyone/sap-rfc
v0.1.0
Published
Typed access to SAP tables over the RFC_READ_TABLE family, for Node.
Readme
Raptor21 SAP RFC for TypeScript
Typed access to SAP tables from Node, over the RFC_READ_TABLE family.
The Node port of Raptor21.SAP.RFC, beside its
JVM sibling Raptor21.SAP.RFC.Java. The
wire behaviour is the .NET library's, deliberately: everything measured there against live systems is
recorded as conformance fixtures, and this runtime's suite asserts the same envelopes, the same
response parses and the same OPTIONS splits, byte for byte.
import { SapClient } from "@raptortwentyone/sap-rfc";
import { Kna1 } from "./sap/Kna1.js";
const sap = SapClient.connect({
name: "S4",
baseUrl: "https://s4.example.com:44300",
user: "READER",
password,
client: "100",
});
const customers = await sap.from(Kna1.ENTITY)
.where(Kna1.Columns.LAND1.eq("TR").and(Kna1.Columns.ERDAT.ge("2024-01-01")))
.select(Kna1.Columns.KUNNR, Kna1.Columns.NAME1, Kna1.Columns.ORT01)
.take(5)
.list();where is sent as SAP's OPTIONS clause and select as its field list, so filtering and projection
happen in SAP rather than after the rows arrive. A condition SAP cannot answer correctly is refused
while the query is built, never silently: a filter on a column whose conversion exit depends on the
system's own customising throws instead of returning confident, wrong rows. For large reads,
for await (const row of query.stream()) pages with the measured ROWCOUNT rules.
How values are represented
Chosen for exactness first, because JavaScript's number cannot carry what some columns hold:
DEC,CURR,QUAN— exact decimal strings. A number holds 53 bits of precision and a packed column up to 31 digits; a float would silently misread the wide ones. Currency scaling — a stored yen10.00really being ¥1000 — shifts the decimal point in the digits, exactly.INT8—bigint. Nineteen digits, same reason.DATS,TIMS— ISO strings (2024-01-15,14:30:45),nullfor never-set. SAP's end-of-day240000is simply"24:00:00"— no sentinel value needed, and it round-trips.- Timestamps — ISO UTC strings with up to seven fractional digits
(
2024-08-04T13:45:30.1234567Z): the stored resolution is 100 nanoseconds, which aDate's milliseconds would silently truncate. RAW—Uint8Array.
Getting the classes
Kna1 above is generated. The scaffolder ships with the .NET package and gained a TypeScript target:
dotnet <package>/tools/net10.0/Raptor21.SAP.RFC.Tool.dll scaffold \
--tables KNA1,TVKO --target typescript --out src/sapOne scaffolder for every language on purpose. The Data Dictionary pipeline — one round trip per table, conversion exits, reference fields, the domain test that tells a timestamp from a quantity — lives once, and each language is only a renderer at the end of it. The generated file is ordinary source: read it, review it, commit it.
No .NET on the machine? The same tool ships as a native, self-contained binary (~7 MB) on each release
of the .NET repository — raptor21-sap-rfc-tool-<platform> under
releases; download the one for your
platform and run it directly with the same arguments, no runtime required.
Requirements
- Node 18 or newer to consume the published package; Node 23.6+ to run this repository's own tests, which go straight through Node's type stripping with no build step.
- No dependencies: the transport is
fetch, the values are strings, numbers and bigints. - A SAP system whose SOAP RFC endpoint (
/sap/bc/soap/rfc) is reachable, and a user withS_RFCauthorisation for the table-reading function modules.
Building
npm ci
npm test
npm run buildnpm run sync-conformance refreshes the conformance snapshot from a sibling
Raptor21.SAP.RFC checkout; the suite fails when the sibling is present and the snapshot is stale.
Licence
MIT — see LICENSE.
Raptor21 SAP RFC is an independent, community-developed library. It is not affiliated with, sponsored by, or endorsed by SAP SE. SAP, SAP S/4HANA and ABAP are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. This library is designed for use with SAP software and is not an SAP product.
