ABAP RFC connectivity from BTP to ABAP systems is supported by SAP Cloud Connector, for BTP Java runtime only. This blog describes the RFC connectivity enablement for BTP Python runtime, so that Python BTP applications can consume ABAP RFCs, as described in Deployment options section of Powerful web applications with old and new ABAP systems and related blogs.
Our “hello world” example is BTP Python buildpack, with Flask server, SAP/PyRFC and SAP NW RFC SDK.
The example source code: SAP-samples/node-rfc-samples//integration/pyrfc_btp can be deployed on BTP, or tested locally inside SAP/fundamental-tools/docker/btp_cflinuxfs4.Dockerfile docker container.
ABAP RFC connectivity from Python on Kyma works practically out of the box, using SAP/PyRFC and SAP NW RFC SDK inside docker container. Try SAP/fundamental-tools/docker/cflinuxfs4.Dockerfile for example.
The ABAP RFC enablement of BTP Python buildpack requires the installation of SAP/PyRFC package and SAP NW RFC SDK installation and registration on BTP host instance. It is similar to RFC enablement NodeJS buildpack: ABAP RFC connectivity from BTP Node.JS buildpack and Kyma,
Python buildpack structure is shown on figure below
Buildpack
SAP NW RFC SDK files for Linux x64 are copied to app/nwrfcsdk folder and excluded from repository, in .gitignore.
SAP NW RFC SDK is not included in SAP/yRFC because the license is different. SAP Support Portal is the only allowed public distribution channel for SAP NW RFC SDK.
The nwrfcsdk folder is added to app MANIFEST.in, to be included in app deployment
include nwrfcsdk
include sapnwrfc.ini
SAP NW RFC SDK home and library paths are added to buildpack manifest.yaml, for build and runtime registration
buildpack/manifest.yaml
cd buildpack/app
pip install pyrfc flask
# do not install from requirements.txt unless your notebook runs on Linux
python serve.py
* Serving Flask app 'serve'
* Debug mode: off
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:3000
* Running on http://10.98.207.132:3000
PyRFC and SAP NW RFC SDK are loaded and PyRFC version shown below
Flask server on http://127.0.0.1:3000
cf push (py3.11.6) main
Pushing app pyrfcapp to org <redacted> / space dev as <redacted>...
Applying manifest file <redacted>/node-rfc-samples/integration/pyrfc_btp/buildpack/manifest.yaml...
Updating with these attributes...
---
applications:
- name: pyrfcapp
path: <redacted>/node-rfc-samples/integration/pyrfc_btp/buildpack/app
memory: 128M
+ default-route: true
stack: cflinuxfs4
buildpacks:
https://github.com/cloudfoundry/python-buildpack.git
command: python serve.py
env:
LD_LIBRARY_PATH: /home/vcap/app/nwrfcsdk/lib
SAPNWRFC_HOME: /home/vcap/app/nwrfcsdk
routes:
- route: pyrfcapp.cfapps.eu10.hana.ondemand.com
Manifest applied
Packaging files to upload...
Uploading files...
Instances starting...
name: pyrfcapp
requested state: started
routes: pyrfcapp.cfapps.eu10.hana.ondemand.com
last uploaded: Mon 30 Oct 15:44:40 CET 2023
stack: cflinuxfs4
buildpacks:
name version detect output buildpack name
https://github.com/cloudfoundry/python-buildpack.git 1.8.15 python python
type: web
sidecars:
instances: 1/1
memory usage: 128M
start command: python serve.py
state since cpu memory disk logging details
#0 running 2023-10-30T14:44:56Z 1.1% 31M of 128M 372.2M of 1G 0/s of unlimited
When finished, the test route https://pyrfcapp.cfapps.eu10.hana.ondemand.com/ shows the same result as local test:
PyRFC with SAP NW RFC SDK on BTP
Once the RFC connectivity from Python is enabled, the connection parameters for ABAP system shall be configured, as described in Deployment options section of Powerful web applications with old and new ABAP systems and in related blogs
Hope you enjoyed reading and stay tuned for more updates.