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

**URL:** <https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712>\
**Category:** Ignition\
**Created:** [November 16, 2020, 11:12pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712 "2020-11-16T23:12:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![framebuilder](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@framebuilder](https://forum.inductiveautomation.com/u/framebuilder)\
**Post date:** [November 16, 2020, 11:12pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/1 "2020-11-16T23:12:44Z")

</div>

I’m trying to determine if there is a method to call SAP RFCs from Ignition. I know Sepasoft has a Business Connector and Interface for SAP but it will probably be cost prohibitive for this particular project where I only need to call one RFC remotely.

I can successfully call the SAP RFC via PyRFC (which uses their Netweaver RFC SDK - NWRFCSDK) on a test Windows box. However, I’m not sure if this is something I can import into Ignition. It would be really great if I could. I’ve read the following:  
[https://support.inductiveautomation.com/index.php?/Knowledgebase/Article/View/98/2/importing-and-using-3rd-party-python-libraries-in-ignition](https://support.inductiveautomation.com/index.php?/Knowledgebase/Article/View/98/2/importing-and-using-3rd-party-python-libraries-in-ignition)

And I think I can find a version of the PyRFC for Python 2.7 (I’m running Ignition 8) but I’m just not that experienced to know if it will work because it depends on some other .dlls in the NWRFCSDK. I mean, can a 3rd party Python library if imported into the user-lib\pylib directory even connect to a dependent .dll or .exe in a Windows directory? Or is Ignition isolated completely in its own JVM or something? Sorry this may be intuitive for some people but I just don’t have the background.

So then I was also wondering about importing a Java Connector for SAP called SAP JCo (sapjco3.jar). I’ve read a few posts about people trying this. Mostly people that could write their own Module with the SDK and that seems way above my knowledge. I also noticed where @Kevin.Herron mentioned putting 3rd party jars in lib/core/gateway but it seems that sapjco3.jar for some reason gets renamed and the .jar itself it hard-coded to look for it’s exact name sapjco3.jar when launched.

So I’m just wondering if any of these options are a possibility for someone without a lot of module SDK or Java experience. Like I said, I was successful with using PyRFC on Windows which provides me with the ease of use of Python but I’m open to other options if you guys have them.

Unfortunately there is no web REST or SOAP endpoint that I can call on the SAP side.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 16, 2020, 11:21pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/2 "2020-11-16T23:21:32Z")

</div>

> [@framebuilder](#):
>
> And I think I can find a version of the PyRFC for Python 2.7 (I’m running Ignition 8) but I’m just not that experienced to know if it will work because it depends on some other .dlls in the NWRFCSDK.

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?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 17, 2020, 12:41am UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/3 "2020-11-17T00:41:07Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![framebuilder](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@framebuilder](https://forum.inductiveautomation.com/u/framebuilder)\
**Post date:** [November 17, 2020, 12:56am UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/4 "2020-11-17T00:56:01Z")

</div>

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 [https://help.sepasoft.com/docs/display/BC/JCo+Library+for+SAP](https://help.sepasoft.com/docs/display/BC/JCo+Library+for+SAP) 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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 17, 2020, 1:15am UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/5 "2020-11-17T01:15:35Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![gnguyen](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gnguyen](https://forum.inductiveautomation.com/u/gnguyen)\
**Post date:** [November 17, 2020, 5:57am UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/6 "2020-11-17T05:57:08Z")

</div>

Hi Phil,

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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 17, 2020, 1:24pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/7 "2020-11-17T13:24:27Z")

</div>

> [@gnguyen](#):
>
> More on this “hacked Modbus Server”?

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:

 ![Screenshot_20201117_081859](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/2/828e7b68f0d924b45c4755dfe839270ed0342390.png)

Oh, no support for Modbus UDP is planned.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 17, 2020, 1:32pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/8 "2020-11-17T13:32:00Z")

</div>

Oh, one more thing:

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

---

<div class="post-metadata">

**Author:** ![phyatt](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/phyatt/32/19545_2.png) [@phyatt](https://forum.inductiveautomation.com/u/phyatt)\
**Post date:** [November 17, 2020, 7:21pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/9 "2020-11-17T19:21:57Z")

</div>

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**

```auto
# 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.

```auto
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.

```auto
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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 17, 2020, 7:35pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/10 "2020-11-17T19:35:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![framebuilder](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@framebuilder](https://forum.inductiveautomation.com/u/framebuilder)\
**Post date:** [November 24, 2020, 4:04am UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/11 "2020-11-24T04:04:42Z")

</div>

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:

```auto
jco.client.ashost=fqdn_of_SAP_server
jco.client.sysnr=00
jco.client.client=100
jco.client.user=SAP_username
jco.client.passwd=SAP_password
jco.client.lang=en
jco.destination.pool_capacity=0

```

Here’s an RFC\_READ\_TABLE example I cobbled together:

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

```

Hope this helps someone else.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 8, 2020, 8:57pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/12 "2020-12-08T20:57:10Z")

</div>

For those interested, beta Modbus announcement here:

> [@Automation Professionals' Advanced Modbus Driver](http://forum.inductiveautomation.com/t/automation-professionals-advanced-modbus-driver/41312):
>
> Automation Professionals is pleased to announce the first beta for its Advanced Modbus Driver, for Ignition version 7.9. Key features: Server mode, emulating one or more slave [devices](https://www.automation-pros.com/modbus/UserManual.pdf), using any of the three typical connection types, including simultaneous connections of multiple types. Client mode, incorporating all three connection modes in one driver. Support for Modbus Function Codes 20 and 21, File Records. Configure protocol tweaks for troublesome devices per slave unit, enabling suppor…

---

<div class="post-metadata">

**Author:** ![mikesch73](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mikesch73](https://forum.inductiveautomation.com/u/mikesch73)\
**Post date:** [May 31, 2021, 1:21pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/13 "2021-05-31T13:21:11Z")

</div>

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 com.sap.conn.jco 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.  
Thanks

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 31, 2021, 1:35pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/14 "2021-05-31T13:35:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mikesch73](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mikesch73](https://forum.inductiveautomation.com/u/mikesch73)\
**Post date:** [June 1, 2021, 11:12am UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/15 "2021-06-01T11:12:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [November 4, 2022, 6:32am UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/16 "2022-11-04T06:32:50Z")

</div>

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

wrapper.java.classpath.1=lib/wrapper.jar  
wrapper.java.classpath.2=lib/core/common/\*  
wrapper.java.classpath.3=lib/core/gateway/\*  
...............................................................................................  
we got this from our ignition.conf file. Do we need to replace or do we need make any changes in this??

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [November 4, 2022, 11:38am UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/17 "2022-11-04T11:38:32Z")

</div>

> [@kavya\_shree](#):
>
> 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.

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:

```auto
# 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/core/common/*
wrapper.java.classpath.3=lib/core/gateway/*
wrapper.java.classpath.4=c:\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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 4, 2022, 12:21pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/18 "2022-11-04T12:21:12Z")

</div>

> [@lrose](#):
>
> replace `c:\Path/To/SAP Jco3/library` with the correct path

And no backslashes, IIRC.

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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 4, 2022, 12:53pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/19 "2022-11-04T12:53:05Z")

</div>

> [@pturmel](#):
>
> You can also drop your jars in one of the existing folders, usually lib/core/gateway.

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.

---

<div class="post-metadata">

**Author:** ![francis.henry](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@francis.henry](https://forum.inductiveautomation.com/u/francis.henry)\
**Post date:** [November 7, 2022, 10:15pm UTC](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712/20 "2022-11-07T22:15:19Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/4/c40f3877ac4031650e5a9469de547f2d56731a45.png)

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/b/abf9ccb204093bb898771d29b865856c7b4de835.png)

It is working fine now!

Thanks!

[Next page](https://forum.inductiveautomation.com/t/connecting-to-sap-with-3rd-party-python-lib-or-sap-jco-jar/40712.md?page=2)
