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

It's unlikely to work if it relies on a DLL.

Unfortunately the SAP JCo connector seems to be a complete dead end even if you are a module developer because module dependencies are unpacked and renamed the same way JAR files placed in lib/core/gateway are.

Maybe another user here has figured something out though?

I briefly looked at the same jars that Sepasoft ended up deploying–official SAP jars. Looked reasonable to use, but that project died (customer’s in-house IT wrote their own interface with the official .NET API for SAP).

{Yeah, I was shocked when I recently saw the price tag Sepasoft put on their SAP and Connector combo. Someone’s going to re-implement it cheaper, eventually. Might even be me.)

Hi Phil,
We’re currently using the .NET Connector but I’d really like to have some scripting functions I could use in Ignition. Don’t get me wrong, the modules from Sepasoft looks to have great features and is certified by SAP but it’s pretty expensive for calling just one BAPI.

I did notice their instructions make it seem as though they figured out a way to import the jars and dll. Maybe they’re only using Gateway scope or using a separate process entirely to hook into the SAP JCo jars.

BTW- we’re still using your Batik SVG Canvas for displaying Cognex camera images and overlays. It’s working great! And we’d definitely be interested if you decide to move forward with an SAP connector. I’ll send you an email.

It won’t be soon, unfortunately. I’m solidly booked for the next couple months. The only module I’m likely to release in the interim is the Modbus Server I’m hacking at. (Plus any v8.1-induced bugs found in my other modules.)


Hi Phil,

More on this “hacked Modbus Server”? Any plan for a UDP Modbus?

I've mentioned it a few times around here, but it implements the server (slave) side of the Modbus protocol so that other masters can connect to Ignition. It supports simultaneous Modbus TCP, Modbus Serial RTU, and Modbus RTU over TCP connections to the configured virtual device. Within the virtual device, multiple units are supported, each with their own data format setttings (word swapping, etc) and configurable ranges of bits and registers to expose. It also supports a configurable number of Modbus "File" registers in each unit (function codes 20 & 21). As a server, the DI and IR memory areas are fully writable.

The driver uses the same general syntax as IA's Modbus driver, with the following enhancements:

  1. Multiple Consecutive Coils or Discrete Inputs can be treated as an integer by adding :n to the bit address, where n is the number of bits (up to 63). LSB first only.
  2. Multiple Bits in any 16-bit register may be treated as an integer by adding .m:n to the register address, where m is the start (low) bit, and n is the number of bits (up to 15). Cannot span registers.
  3. File aka "Extended" registers use the XR prefix and support all of the bit access, conversion, and multiword datatype modifiers available for holding registers (and input registers).

There are two major features not present in this module:

  1. No mappings. Not supported and not going to be supported.
  2. No one-based addressing. Zero-based only.

However, in lieu of the above, this driver implements browsing of configured units and the configured address ranges of each units memory areas. Available data type modifiers are displayed in the browse tree under each 16-bit register. Large lists of addresses are broken into groups of 1000 to minimize browse delays. Each displayed base address shows the one-based classic address equivalent as an "AKA" in the description. Here's a tease from my testing server:

Oh, no support for Modbus UDP is planned.

1 Like

Oh, one more thing:

My new Modbus module also implements client connections with the above addressing and browsing functionality. (:

1 Like

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\SAPJco3/sapjco3.jar

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1\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.

passwd=password  (The SAPJco3 library will update a clear text password with an encrypted version after the first connection.)

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 import JCoDestinationManager
destination = JCoDestinationManager.getDestination(sapSystem)
function = destination.getRepository().getFunction("Z_OEE_RATE_LIST")
function.getImportParameterList().setValue("WERKS", werks)
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.



Nice job @phyatt, I hadn’t thought about approaching it this way.

Thanks @phyatt! I followed your example and it was enough to get me started but I did have one issue. Maybe due to the version of SAP JCo that I’m running (3.1.3). My .jcoDestination file parameters needed to include the jco.client prefix like this:


Here’s an RFC_READ_TABLE example I cobbled together:

	from import JCoDestinationManager
	destination = JCoDestinationManager.getDestination(sapSystem)
	function = destination.getRepository().getFunction("RFC_READ_TABLE")
	inputTableParam = function.getTableParameterList().getTable("FIELDS")
	inputTableParam.setValue("FIELDNAME", "CHECT")
	inputParamList = function.getImportParameterList()
	inputParamList.setValue("QUERY_TABLE", "PAYR")
	inputParamList.setValue("DELIMITER", ";")
	optionsTableParam = function.getTableParameterList().getTable("OPTIONS")
	optionsTableParam.setValue("TEXT", "CHECT = '436396'")
	table = function.getTableParameterList().getTable("DATA")
	print table

Hope this helps someone else.

For those interested, beta Modbus announcement here:

Hello All,
I followed everything as described, but I don’t succeed.
I suspect I already fail importing the jar file into Ignition 7.9.12. I get always the error: “ImportError: No module named sap” with the link to the line “from import JCoDestinationManager”
Does anyone have any idea what I can try here. With the / \ I have already tested all variations in the ignition.conf file. The gateway runs on a Windows Server 2012 R2 but also on my testenvironment a Windows 7 machine it give the same error. The SAP Java Connector seams to be setup well.

What scope are you testing your script in? The approach outlined above would only make the classes available in the gateway, so you can’t test using the Designer script console for example.

Hi Kevin, thank you for your fast reply. The script did run as a Global script but called from a button action scrip of a client. When I call the script now from a tag change script it works.

we are trying to map those 3 jar files but we don't have catapult.jar. How we can get this file? Do we need to download or suggest how we can get it.

Java Classpath (include wrapper.jar) Add class path elements as

needed starting from 1**
we got this from our ignition.conf file. Do we need to replace or do we need make any changes in this??

Pretty sure you don't need the catapult.jar. Rather you need to add an additional class path to your conf file.

It should look something like:

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1**\Path/To/SAP Jco3/library/sapjco3.jar

You'll need to replace c:\Path/To/SAP Jco3/library with the correct path to where you placed the library on the Gateway Machine.

And no backslashes, IIRC.

You can also drop your jars in one of the existing folders, usually lib/core/gateway.

1 Like

Not this one. We copy and rename JARs to another location before loading them (for reasons lost to time) and this idiotic library does some kind of introspection that requires the JAR name to be completely unmodified from how they shipped it.


Could you show me how you got the JCoDestinationManager to work? I am always getting SAP destination does not exist. Script is executing from gateway event and I have tried tag scripts with same result...

I have read the examples from sapjco but I really can't figute how to register the destination.

SAPJCO seems to be loading correctly.

EDIT: It looks like having Sepasoft connector and this kind of script will block from getting a new provider:

It is working fine now!


1 Like

we followed all the above steps what you suggested. Please find the details below:

  1. we downloaded SAPJco3.jar file and mapped the path into ignition.conf file.

Java Classpath (include wrapper.jar) Add class path elements as# needed starting from 1**

Java Classpath for Interface for SAP ERP\Program Files/InductiveAutomation/Ignition/user-lib/jco/sapjco3.jar\Program Files/Inductive Automation/Ignition/lib/sapjco3.jar

path for Link Ignition site-packages with jpython site-packages
2. we created DEV.jcoDestination file and kept in Ignition folder and we added below details.

ashost='' #147.185.XX.XX
3. we are writing python script to call BAPI in Script Console in Ignition. But getting error. Please find below code and attached error image.

from import *
#from import JCoDestinationManager
destination = JCoDestinationManager.getDestination(sapSystem)


Java Traceback:
Traceback (most recent call last):
File "", line 4, in
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: Could not initialize class


Please guide us after this. It will be very helpful for continuing with Ignition Software.

EDIT: We are able to read DEV.jcoDestination file, but when we are trying to ping it's giving "No User identity is configured" Error.
Currently I have installed SAPJco3 jar and Ignition in my local system and I have access of SAP GUI. I have mapped same credentials and other SAP details in DEV.jcoDestination, I have also created one Technical User to call BAPI, but from both User, we are getting same error, Please help