Connecting to SAP with 3rd party Python lib or SAP JCo jar

I’m using SAPJco3 for RFC calls to SAP and it works nicely.

  • Place the SAPJco3 library in a folder on your gateway. (c:\SAPJco3 for example) Be sure to get the bit version to match your Java environment. (i.e.: 64 bit SAPJco3 library)

  • Edit the ignition.conf file and add wrapper.java.classpath.3=c:\SAPJco3/sapjco3.jar

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1
wrapper.java.classpath.1=lib/wrapper.jar
wrapper.java.classpath.2=lib/catapult.jar
wrapper.java.classpath.3=c:\SAPJco3/sapjco3.jar
  • Place required .jcoDestination files in the \Program Files\Inductive Automation\Ignition folder.

This could be something like: DEV.jcoDestination, QAS.jcoDestination, PRD.jcoDestination
This format works for me.

ashost=192.168.x.x
sysnr=00
client=110
user=username
passwd=password  (The SAPJco3 library will update a clear text password with an encrypted version after the first connection.)
lang=en
pool_capacity=0

Limit your function calls to the gateway scope or you’ll need the SAPJco3 setup on your clients!

Sample function to return a table from SAP. Note: sapSystem is a string representing the file name of your destination file without the ‘.jcoDestination’ extension.

def Z_OEE_RATE_LIST(werks,sapSystem):
# Plant Number (werks) is passed in - Datasets returned
from com.sap.conn.jco import JCoDestinationManager
destination = JCoDestinationManager.getDestination(sapSystem)
function = destination.getRepository().getFunction("Z_OEE_RATE_LIST")
function.getImportParameterList().setValue("WERKS", werks)
function.execute(destination)
#
ds = function.getTableParameterList().getTable("OEE_RATE_LIST")
return ds

You can send and receive tables and individual values as needed.

I hope that helps. Let me know if you need clarification.

Paul

7 Likes