Python bindings for SAP NetWeaver RFC SDK
Reason this release was yanked:
No longer supported, see https://github.com/SAP/PyRFC/issues/372
Project description
PyRFC
Asynchronous, non-blocking SAP NetWeawer RFC SDK bindings for Python.
- Features
- Supported platforms
- Requirements
- Download and installation
- Getting started
- SPJ articles
- How to obtain support
- Contributing
- License
Features
- Client, Throughput and Server bindings
- Automatic conversion between Python and ABAP datatypes
- Stateless and stateful connections (multiple function calls in the same ABAP session / same context)
- Sequential and parallel calls, using one or more clients
Supported platforms
-
Cloud platforms are not supported, see #205
-
Python 3
-
Windows 10 and macOS >= 10.15 supported by pre-built wheels and build from source installation
-
Linux wheels are supported by build from source installation only
-
Prebuilt Centos wheels are attached to the latest release on GitHub
-
Pre-built portable Linux wheels
-
are not supported, neither issues related to portable Linux wheels
-
must not be distributed with embedded SAP NWRFC SDK binaries, only private use permitted
-
-
Platforms supported by SAP NWRFC SDK can be supported by build from source
Requirements
All platforms
-
SAP NWRFC SDK 7.50 PL3 or later must be downloaded (SAP partner or customer account required) and locally installed
- Using the latest version is recommended as SAP NWRFC SDK is fully backwards compatible, supporting all NetWeaver systems, from today S4, down to R/3 release 4.6C.
- SAP NWRFC SDK overview and release notes
-
Build from source on older Linux systems, may require
uchar.h
file, attached to SAP OSS Note 2573953, to be copied to SAP NWRFC SDK include directory
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
- The macOS firewall stealth mode must be disabled (Can't ping a machine - why?):
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode off
-
Remote paths must be set in SAP NWRFC SDK for macOS: documentation
-
When the node-rfc is started for the first time, the popups come-up for each NWRFC SDK library, to confirm it should be opened. If SDK is installed in admin folder, the node-rfc app shall be that first time started with admin privileges, eg.
sudo -E
Download and installation
pip install pyrfc
Cython is required on Linux platforms, for the the default build from source installation method.
Build from source can be also requested on Windows and Darwin platforms:
pip install pyrfc --no-binary :all:
# or
PYRFC_BUILD_CYTHON=yes pip install pyrfc --no-binary :all:
Alternative build from source installation:
git clone https://github.com/SAP/PyRFC.git
cd PyRFC
python setup.py bdist_wheel
pip install --upgrade --no-index --find-links=dist pyrfc
See also the pyrfc documentation, complementing SAP NWRFC SDKdocumentation, especially SAP NWRFC SDK 7.50 Programming Guide.
Getting started
Note: The package must be installed before use.
Call ABAP Function Module from Python
In order to call remote enabled ABAP function module (ABAP RFM), first a connection must be opened.
from pyrfc import Connection
conn = Connection(ashost='10.0.0.1', sysnr='00', client='100', user='me', passwd='secret')
Connection parameters are documented in sapnwrfc.ini
file, located in the SAP NWRFC SDK demo
folder. Check also section 4.1.2 Using sapnwrfc.ini
of SAP NWRFC SDK 7.50 Programming Guide.
Using an open connection, remote function modules (RFM) can be invoked. More info in pyrfc documentation.
# ABAP variables are mapped to Python variables
result = conn.call('STFC_CONNECTION', REQUTEXT=u'Hello SAP!')
print (result)
{u'ECHOTEXT': u'Hello SAP!',
u'RESPTEXT': u'SAP R/3 Rel. 702 Sysid: ABC Date: 20121001 Time: 134524 Logon_Data: 100/ME/E'}
# ABAP structures are mapped to Python dictionaries
IMPORTSTRUCT = { "RFCFLOAT": 1.23456789, "RFCCHAR1": "A" }
# ABAP tables are mapped to Python lists, of dictionaries representing ABAP tables' rows
IMPORTTABLE = []
result = conn.call("STFC_STRUCTURE", IMPORTSTRUCT=IMPORTSTRUCT, RFCTABLE=IMPORTTABLE)
print result["ECHOSTRUCT"]
{ "RFCFLOAT": 1.23456789, "RFCCHAR1": "A" ...}
print result["RFCTABLE"]
[{ "RFCFLOAT": 1.23456789, "RFCCHAR1": "A" ...}]
Finally, the connection is closed automatically when the instance is deleted by the garbage collector. As this may take some time, we may either call the close() method explicitly or use the connection as a context manager:
with Connection(user='me', ...) as conn:
conn.call(...)
# connection automatically closed here
Alternatively, connection parameters can be provided as a dictionary:
def get_connection(conn_params):
"""Get connection"""
print 'Connecting ...', conn_params['ashost']
return Connection(**conn_param)
from pyrfc import Connection
abap_system = {
'user' : 'me',
'passwd' : 'secret',
'ashost' : '10.0.0.1',
'saprouter' : '/H/111.22.33.44/S/3299/W/e5ngxs/H/555.66.777.888/H/',
'sysnr' : '00',
'client' : '100',
'trace' : '3', #optional, in case you want to trace
'lang' : 'EN'
}
conn = get_connection(**abap_system)
Connecting ... 10.0.0.1
conn.alive
True
See also pyrfc documentation for Client Scenario
Call Python function from ABAP
# create server for ABAP system ABC
server = Server({"dest": "gateway"}, {"dest": "MME"}, {"port": 8081, "server_log": False})
# expose python function my_stfc_connection as ABAP function STFC_CONNECTION, to be called from ABAP system
server.add_function("STFC_CONNECTION", my_stfc_connection)
# start server
server.start()
# get server attributes
print("Server attributes", server.get_server_attributes())
# stop server
input("Press Enter to stop servers...")
server.stop()
print("Server stoped")
See also pyrfc documentation for Server Scenario and server example source code.
SPJ articles
Highly recommended reading about RFC communication and SAP NW RFC Library, published in the SAP Professional Journal (SPJ)
How to obtain support
If you encounter an issue or have a feature request, you can create a ticket.
Check out the SAP Community (search for "pyrfc") and stackoverflow (use the tag pyrfc), to discuss code-related problems and questions.
Contributing
We appreciate contributions from the community to PyRFC! See CONTRIBUTING.md for more details on our philosophy around extending this module.
License
Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.
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 Distribution
Built Distributions
Hashes for pyrfc-2.7.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 706349d50eb5ef8dfc4fcc645007d0e1d51a9df5b40a8d4695d03c4331e3a069 |
|
MD5 | 012c485c92ca64eeded4108505cbbcfc |
|
BLAKE2b-256 | f9bfa7b116ec31aad43bbdbabf8bc88e9b088e3ea289fb7b5d70300471889d26 |
Hashes for pyrfc-2.7.1-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | edcd34255dec4a2bf5a55c56ed4ecdd1aebb03d33bd6a31f1d037a900f286146 |
|
MD5 | 5c362c2bbd1f5bf1596cc3abcfbbd207 |
|
BLAKE2b-256 | b4cbf888666e40b4c9a4a51bd386013be3dddc2966297c5505c7ac656cbf2265 |
Hashes for pyrfc-2.7.1-cp311-cp311-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ddae4a3cc0806e40041934adb35d14374f5a043892c5fe8fec7190a6c74ea6b |
|
MD5 | d83dc129ae13405ae7a7361cdc7e886f |
|
BLAKE2b-256 | d1e60e1fd77ad8576b400d0af47a8f6a6532e3d12fab6e5666135a468bb169bb |
Hashes for pyrfc-2.7.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccbf5ae28cef2f0997392929ed366d0b992e7c227e5b27f8130ee6a83af10b33 |
|
MD5 | c3f25378f44178cd9d22b02ed6abf3fd |
|
BLAKE2b-256 | ed69b5310614ea2cf7108124d75e011d7645b421cf9144c936275e6e1569f133 |
Hashes for pyrfc-2.7.1-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbfa581406f796b80e35a2772b250ef07f638c176c56533709c34b1ebdcf2e85 |
|
MD5 | d197a3fec582389ab370b26b883e0043 |
|
BLAKE2b-256 | 393c9f4424228ef8cfd33df61819faab454308dd92a640825a3221bb52d4037f |
Hashes for pyrfc-2.7.1-cp310-cp310-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60f37c54dfcafb4cfcec7c235d96c8539f0af18875cbf62693b52a3395627346 |
|
MD5 | 9ddf0d13e5e8595c68462e208ff35b1c |
|
BLAKE2b-256 | 310b22984f0655c3c36972d8fba9b3aaa1d86112e04494e76b8ad031bbebdce8 |
Hashes for pyrfc-2.7.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5406e1a8b07115a211bdea90a8b6b31b45924279bf99c674b1f13574aef43bd6 |
|
MD5 | ae793124d00a36e83b8eaa8ac052851d |
|
BLAKE2b-256 | f57bf7100c577ebef1cf19219b8df0693738824e528a39d8907c5c82d3cd9ed0 |
Hashes for pyrfc-2.7.1-cp39-cp39-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b97ebbd900ae4f12dd3a5fa9cf5baf287d1dc14d2eaab2c079fa8c01114c1369 |
|
MD5 | e00a7aed0b2c275375dd4748ea30835f |
|
BLAKE2b-256 | 53001210406ffbdee16224378895a9ae7bcd187ff04be29c015b89a379517b50 |
Hashes for pyrfc-2.7.1-cp39-cp39-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 119e913b55ff022459d46f2195754d1802795ec6de37a53e36d255d81c5e8857 |
|
MD5 | f3dc05b576960897f679e4337ce4ae5e |
|
BLAKE2b-256 | 349b03d26249a0747a31767f776b6e08ec88ee9b1f4852c98fefd6461ed2a61a |
Hashes for pyrfc-2.7.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3160f99e9592630ed94709b7a4e59a834c7d0097ad53dc6eadf7ed338dd4b98 |
|
MD5 | e34e211556fcb9d025a848f745bef708 |
|
BLAKE2b-256 | 0cf834539f1ce10557a0117d0150564c324614eb3eba22c2faa9b8225105d1b5 |
Hashes for pyrfc-2.7.1-cp38-cp38-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ea4e23ce20324e55855939feba01c8b6258bebab64d6a7d84c63beefbe288a3 |
|
MD5 | 05eb8471306436036fbe42f03af72144 |
|
BLAKE2b-256 | 9614359463db07272c7f70d73f1365c4ac4668182443b9537817bf79b986ef28 |
Hashes for pyrfc-2.7.1-cp38-cp38-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a27515229ef55a4b5d6ddfa89ba3ecef096dbede5417de80ad6e276b0eed835 |
|
MD5 | dc1c674bf8ccb544ef3b4d2a8018d34e |
|
BLAKE2b-256 | f1184b8e4c7a8202463157f53b59afc5dc4ee29f4b199263d0b03da128e6355e |
Hashes for pyrfc-2.7.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd24772e93b3134fa37c5e1f86375cd35aa38475782a8fdbf5b356969e5adfa1 |
|
MD5 | 8fc70b1ce81350b8038acf8beafb07d9 |
|
BLAKE2b-256 | 1a8ceaadcea6b9ca417d1e40db2fe0967915039a90f398411b7a5a373dd61573 |
Hashes for pyrfc-2.7.1-cp37-cp37m-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 546c13c2ee28122bba04c2b17d62a122454993be4745760d334fa1e237e27bcc |
|
MD5 | 91243516def6763b2196f523fa7ddec7 |
|
BLAKE2b-256 | 6587c44246cc7bac8faf88723cfb8a5d2660c351b9b1536d96c6d8f9f8274a36 |
Hashes for pyrfc-2.7.1-cp37-cp37m-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0d93e92054024cb48ddee35a4a582947361236ac78ff78270b26dba5c9bb0e1 |
|
MD5 | 0e3b70934f5e163d5d7d3e21fe30622b |
|
BLAKE2b-256 | e346475a7de22c7c9f6ed9f58fcf2b140c2c269105b8a9e6280dae3721717c0a |