How to extract table level data from SAP using Python

How to extract table level data from SAP using Python
Use python PyRFC and Pandas to extract data from SAP Tables

Prerequisite

you need a s type user id so that you can download the SAP NW RFC SDK 7.5.0.11

SAP NW RFC SDK 7.50.11

  • see SAP Note 3274546 for a list of bug fixes and enhancements made with this patch release
  • Using the latest version is recommended as SAP NWRFC SDK is fully backwards compatible, from today S4, down to R/3 release 4.6C.
  • Can be downloaded from SAP Software Download Center of the SAP Support Portal, like described at https://support.sap.com/nwrfcsdk.
  • If you are lacking the required authorization for downloading software from the SAP Service Marketplace, please follow the instructions of SAP Note 1037575 for requesting this authorization.

Windows

Visual C++ Redistributable Package for Visual Studio 2013 is required for runtime, see SAP Note 2573790 - Installation, Support and Availability of the SAP NetWeaver RFC Library 7.50

Build toolchain for Python 3 requires Microsoft C++ Build Tools, the latest version recommended

Build toolchain for Python 2 requires Microsoft Visual C++ 9.0

Due to a change introduced with Python 3.8 for Windows, PATH directories are no longer searched for DLL. The SAP NWRFC SDK lib path is no longer required on PATH, for Python >= 3.8.

macOS

Remote paths must be set in SAP NWRFC SDK for macOS: documentation

When the PyRFC is started for the first time, the popups may come-up for each NWRFC SDK library, to confirm the usage. If SAP NW RFC SDK is installed in admin folder, the app shall be first time started with admin privileges, eg. sudo -E

Download and installation

pip install pyrfc

Python code to extract LFA1 from SAP ECC

To extract data from the SAP ECC table LFA1 using Python, you can use the SAP Python Connector (PyRFC) library. Here is an example code snippet that demonstrates how to do this:

Read the full story

Sign up now to read the full story and get access to all members-only posts.

Subscribe
Already have an account? Sign in
Great! Next, complete checkout for full access to Datamug.
Welcome back! You've successfully signed in.
You've successfully subscribed to Datamug.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.