This release is a pre-release and may not be stable for production use.
Raptor21 SAP RFC for Python
Typed access to SAP tables from Python, over the RFC_READ_TABLE family.
The Python port of Raptor21.SAP.RFC, beside
its JVM and
Node siblings. 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. SAP archived its own pyrfc connector in 2024; this
library needs no SAP SDK at all — the transport is the system's generic SOAP RFC endpoint, spoken
through urllib.
import datetime
from raptor21_sap_rfc import SapClient, SapDestination
from sap.kna1 import Kna1
sap = SapClient.connect(SapDestination(
name="S4",
base_url="https://s4.example.com:44300",
user="READER",
password=password,
client="100",
))
customers = (
sap.query(Kna1.ENTITY)
.where(Kna1.Columns.LAND1.eq("TR") & Kna1.Columns.ERDAT.ge(datetime.date(2024, 1, 1)))
.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 raises instead of returning confident, wrong rows. For large reads,
for row in query.stream(): pages with the measured ROWCOUNT rules.
How values are represented
DEC,CURR,QUAN—decimal.Decimal. Exact at any width, which is the whole point; a float would misread the wide ones. Currency scaling — a stored yen10.00really being ¥1000 — shifts the exponent, exactly.INT1throughINT8—int. Arbitrary precision; nineteen digits are just an int.DATS,TIMS—datetime.date/datetime.time,Nonefor never-set. SAP's end-of-day240000reads asEND_OF_DAY(time.max) and renders back as240000, so it round-trips.- Timestamps — timezone-aware
datetime.datetimein UTC. One honest cost, stated rather than hidden:datetimeholds microseconds and the long form holds seven fractional digits, so the last digit is truncated on read;row.get_rawstill hands over the stored text unconverted. RAW—bytes.
Getting the classes
Kna1 above is generated. The scaffolder ships with the .NET package and gained a Python target:
dotnet <package>/tools/net10.0/Raptor21.SAP.RFC.Tool.dll scaffold \
--tables KNA1,TVKO --target python --out sap
One 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
- Python 3.10 or newer. No dependencies: the transport is
urllib, the values aredecimalanddatetime. - 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
set PYTHONPATH=src # or: export PYTHONPATH=src
python -m unittest discover -s tests
python scripts/sync_conformance.py 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.
Release files for raptor21-sap-rfc 0.1.0rc1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| raptor21_sap_rfc-0.1.0rc1.tar.gz | 51.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| raptor21_sap_rfc-0.1.0rc1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 104.1 kB
Release files / raptor21_sap_rfc-0.1.0rc1.tar.gz
| Download URL | raptor21_sap_rfc-0.1.0rc1.tar.gz |
|---|---|
| Size | 51.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80c12ffb4e4d6e5505d878522dca3aaa2d05b58bdc98d4e0512776e85b0c0b0c
|
|
BLAKE2b-256 checksum How to use checksums |
fd4e4cab22ee21ecb06fb68dee0cdd06cd0c3e411422873d4a58dd5d06a5320f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.
Transparency logRelease files / raptor21_sap_rfc-0.1.0rc1-py3-none-any.whl
| Download URL | raptor21_sap_rfc-0.1.0rc1-py3-none-any.whl |
|---|---|
| Size | 52.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
00a678b0aae944a2268ec1f459e02b52f2fb8e042ec3bbe8723c0e852b35418a
|
|
BLAKE2b-256 checksum How to use checksums |
3f9f78ab2533c6bfd7002eeb100952ca0c5bde8ce8a9a6dd3d5ce905dd976910
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.
Transparency log