Skip to main content

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:
    • SapRfcConnector
    • SapFunctionCaller

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_HOME pointing 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:

  • user
  • passwd
  • ashost
  • sysnr

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(...).
    • None becomes empty string.
    • bytes are decoded as Python bytes-to-str cast result.

C++ design notes

  • SapRfcConnector is 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) -> bool
  • check_connection() -> bool
  • close_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.

Metadata

Release files for sap-rfc-connector 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sap-rfc-connector 0.3.7
File Size Uploaded Provenance Actions
sap_rfc_connector-0.3.7.tar.gz 12.7 kB With provenance Details for sap_rfc_connector-0.3.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sap-rfc-connector 0.3.7
File Interpreter ABI Platform Actions
sap_rfc_connector-0.3.7-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details for sap_rfc_connector-0.3.7-cp310-cp310-manylinux_2_28_x86_64.whl

Total release size: 4.3 MB

Release files / sap_rfc_connector-0.3.7.tar.gz

Download URL sap_rfc_connector-0.3.7.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dc4f300d4088d6262599f6b5ac49057a0e810e2ba82c22d0d2feaddd01d058f8
BLAKE2b-256 checksum
How to use checksums
09a1097d20cabd63f1fbad06694fe9c99efe4122c64f514046b6d5492109a010
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 3, 2026.

Transparency log

Release files / sap_rfc_connector-0.3.7-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL sap_rfc_connector-0.3.7-cp310-cp310-manylinux_2_28_x86_64.whl
Size 4.3 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3ab359fa466503988f180832d52c9b5ca306e6e33dbc219300e26eba4e1577d2
BLAKE2b-256 checksum
How to use checksums
69b7557e6ae4238e7055a95126f28325e64cf5accb7d045108607196a6acabed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 3, 2026.

Transparency log

Security for sap-rfc-connector 0.3.7

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sap_rfc_connector-0.3.7.tar.gz

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 Jun 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page