Skip to main content

Read data from SAP R/3 Systems

Project description

pyrfc-read

Query table data from SAP R/3 Systems

PyPI Latest Release PyPI downloads License Code style: black Imports: isort codecov

Install

pip install pyrfc-read

Prerequisites

SAP NW RFC SDK must be installed (https://support.sap.com/nwrfcsdk).

Demo

from pyrfc_read import Connection

# Define credentials to the SAP R/3 System
#  many combinations of key-values will work here, and these are just an example
#  https://help.sap.com/doc/saphelp_nw74/7.4.16/de-DE/48/b0ff6b792d356be10000000a421937/frameset.htm
credentials = dict(
    ashost="hostname",
    sysnr="system_number",
    client="client",
    user="user",
    passwd="password",
    lang="EN",
)

# Open connection to the SAP R/3 System
with Connection(**credentials) as conn:
    # Confirm connection active by having SAP echo a message
    message = "Hello world!"
    response = conn.echo(message)

    # Get number of entries in table
    table = "T001"
    entries = conn.number_entries(table)

    # Get table description
    #  in any supported language by SAP Language Code
    #  https://help.sap.com/doc/saphelp_nw73ehp1/7.31.19/en-US/c1/ae563cd2ad4f0ce10000000a11402f/content.htm?no_cache=true
    description = conn.table_description(table, language="E")

    # Search tables by description
    description = "data that I need"
    tables = conn.find_tables_by_description(description, language="E")

    # Get table metadata about its fields
    field_info = conn.field_info(table, descriptions=True, language="E")

    # Read table table, only for select fields, matching where conditions
    fields = [
        "BUKRS",  # Company code
        "BUTXT",  # Name of company
    ]
    wheres = [
        "MANDT = 100",  # Client 100
        ["BUKRS", "in", ["0001", "0002", "0003"]],  # Only company codes 1, 2 and 3
    ]
    data = conn.query(
        table,
        fields,  # optional, but requesting less fields reduces load on SAP
        wheres,  # optional
        field_info=field_info,  # optional, but makes it faster if you already it
        batch_rows=1000,  # optional, handles batching rows to not exceed SAP's output limit
        chunk_rows=100,  # optional, handles chunking long wheres conditions to not exceed SAP's input limit
    )

License

This project is licensed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrfc_read-1.0.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

pyrfc_read-1.0.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file pyrfc_read-1.0.1.tar.gz.

File metadata

  • Download URL: pyrfc_read-1.0.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pyrfc_read-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2a35dc7719aed636a6df9a58326362e0d6c57e02b74acefe2794bf0c04ef81d5
MD5 6a92daeb2e0acd67c39423f25d672d01
BLAKE2b-256 873bf4589b9131964c8629a9a2443dd04cc62447ae613d911263f398872f6ac2

See more details on using hashes here.

File details

Details for the file pyrfc_read-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyrfc_read-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pyrfc_read-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6a61f4c4cf4ef685782021fb6e8332646c3023441618d4976a24049b3b874376
MD5 0535d8144db7237e5df9d2250664223c
BLAKE2b-256 56cebe3d45c52c78e5e5c6a59fb36fe70a7e914cb2df32aa161f94cc4bf490cc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page