SAP RFC wrapper written in C++ with Python bindings
Project description
sap_rfc_connector
sap_rfc_connector is a C++17 + pybind11 wrapper around the SAP NetWeaver RFC SDK.
It exposes a small Python API for opening a SAP connection, calling RFC functions, and reading metadata.
What this package provides
- Python extension module:
sap_rfc_connector - C++ connector class:
SapRfcConnector - C++ function caller:
sap_rfc::SapFunctionCaller - Python bindings for:
SapRfcConnectorSapFunctionCaller
All RFC payload values are currently exchanged as strings (dict[str, str] style), including table rows.
Requirements
- Python
>=3.7 - C++ compiler with C++17 support
- SAP NetWeaver RFC SDK (headers + libraries)
- Environment variable
SAPNWRFC_HOMEpointing to the SDK root
Expected SDK layout:
${SAPNWRFC_HOME}/include${SAPNWRFC_HOME}/lib
Build / Install
From this directory:
python -m pip install --upgrade pip setuptools wheel pybind11
python -m pip install .
For local development build:
python setup.py build_ext --inplace
Quick start (Python)
from sap_rfc_connector import SapRfcConnector, SapFunctionCaller
conn = SapRfcConnector(
user="YOUR_USER",
passwd="YOUR_PASSWORD",
ashost="YOUR_ASHOST",
sysnr="00",
)
caller = SapFunctionCaller(conn)
result = caller.call(
"STFC_CONNECTION",
REQUTEXT="Hello SAP",
)
print(result)
Example with table parameters:
result = caller.call(
"BBP_RFC_READ_TABLE",
QUERY_TABLE="KONP",
DELIMITER="|",
ROWCOUNT=1000,
FIELDS=["KNUMH", "KOPOS", "KAPPL", "KSCHL", "KBETR"],
OPTIONS=[{"TEXT": "KAPPL = 'KA'"}],
)
Python binding behavior
SapRfcConnector(**kwargs) validation
The kwargs constructor requires:
userpasswdashostsysnr
If one is missing, it raises ValueError.
If connection fails, it raises RuntimeError.
SapFunctionCaller.call(func, **kwargs)
Binding-side parsing rules:
- Non-list kwargs are treated as scalar RFC params.
- List kwargs are treated as table params.
- Special-case
FIELDS=["COL1", "COL2"]is converted to:[{"FIELDNAME": "COL1"}, {"FIELDNAME": "COL2"}]
- Table row dict values are normalized to string via Python
str(...).Nonebecomes empty string.bytesare decoded as Python bytes-to-str cast result.
C++ design notes
SapRfcConnectoris intentionally non-copyable and non-movable to avoid handle ownership bugs.- RFC function handles are wrapped with RAII (
RfcFunctionHandle). - Input table field write errors now fail fast with an exception (no silent partial row writes).
- Output field extraction uses a safe fallback marker when SAP field read fails:
"<unreadable:RFCTYPE_...>"
Encoding behavior
utils::fromSAPUC attempts UTF conversion first.
If conversion fails, it returns escaped code units (\uXXXX) instead of replacing data with spaces.
Public API summary
SapRfcConnector
connect(user, passwd, ashost, sysnr) -> boolcheck_connection() -> boolclose_connection()get_library_info() -> dict[str, int]
sap_rfc::SapFunctionCaller
get_function_description(function_name) -> list[dict[str, str]]call(func, params, tables) -> dict[str, list[dict[str, str]]]get_table_metadata(table_name) -> list[dict[str, str]]
Notes for high-volume workloads
Current API materializes output tables in memory as nested Python/C++ maps of strings. For very large result sets, plan calls in chunks at the query/source level where possible.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sap_rfc_connector-0.3.6-cp310-cp310-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: sap_rfc_connector-0.3.6-cp310-cp310-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 4.3 MB
- Tags: CPython 3.10, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61fc1ff79f769f5ee5ccbc965a0f156ab15abdaf5b0777261eb9b0ebc024a50d
|
|
| MD5 |
79a04a4a038224195d250aa877f4fa0a
|
|
| BLAKE2b-256 |
f4f1ef9f24b8bc9aac5459bb28d83fc5e713eda924e59286c8a0130cc2df547f
|
Provenance
The following attestation bundles were made for sap_rfc_connector-0.3.6-cp310-cp310-manylinux_2_28_x86_64.whl:
Publisher:
publish_to_pypi.yml on dyvenia/sap_rfc_connector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sap_rfc_connector-0.3.6-cp310-cp310-manylinux_2_28_x86_64.whl -
Subject digest:
61fc1ff79f769f5ee5ccbc965a0f156ab15abdaf5b0777261eb9b0ebc024a50d - Sigstore transparency entry: 1409420115
- Sigstore integration time:
-
Permalink:
dyvenia/sap_rfc_connector@46e06b418d2faf78c83a07e243c276ea565af1d0 -
Branch / Tag:
refs/heads/pypi_fix - Owner: https://github.com/dyvenia
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_to_pypi.yml@46e06b418d2faf78c83a07e243c276ea565af1d0 -
Trigger Event:
workflow_dispatch
-
Statement type: