Connecting Ignition and SAP with SAP JCo Jar

Hi Team,
We are trying to connect Ignition with SAP. Requirement is to fetch data from SAP without using Sepasoft.

we followed all the following steps to configure as suggested from other link.
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

wrapper.java.classpath.1=lib/wrapper.jar
wrapper.java.classpath.2=lib/core/common/*
wrapper.java.classpath.3=lib/core/gateway/*

Java Classpath for Interface for SAP ERP

wrapper.java.classpath.4=C:\Program Files/InductiveAutomation/Ignition/user-lib/jco/sapjco3.jar
#wrapper.java.classpath.4=lib/sapjco3.jar
#wrapper.java.classpath.4=C:\Program Files/Inductive Automation/Ignition/lib/sapjco3.jar

path for Link Ignition site-packages with jpython site-packages

wrapper.java.classpath.5=lib/jython.jar
....................................................................................................................
2. we created DEV.jcoDestination file and kept in Ignition folder and we added below details.

ashost='XXX.corp.timken.com' #147.185.XX.XX
sysnr='01'
client=100
user='XYZ'
passwd='*****'
lang='en'
pool_capacity=0
..............................................................................................................
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.

sapSystem='DEV'
from com.sap.conn.jco import *
#from com.sap.conn.jco import JCoDestinationManager
destination = JCoDestinationManager.getDestination(sapSystem)

Error

Java Traceback:
Traceback (most recent call last):
File "", line 4, in
at com.sap.conn.jco.JCoDestinationManager.getDestination(JCoDestinationManager.java:56)
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 com.sap.conn.jco.JCo

...........................................................

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

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

Thank you

Assuming the paths you entered as additional classpaths are correct, which I'm not sure they are because you seem to have used inconsistent forward/back-slashes and spacing in "Inductive Automation" between examples, you would only be adding this JAR to the classpath in the gateway scope, which means you won't be able to run any of this code from the Designer or Client, including the Designer Script Console.

Hi,

what about create youre destination with a script?

	connectProperties = Properties();
	connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, settings["host"]);
	connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,  settings["sys"] );
	connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, settings["client"]);
	connectProperties.setProperty(DestinationDataProvider.JCO_USER,   settings["user"]);
	connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, settings["password"]);
	connectProperties.setProperty(DestinationDataProvider.JCO_LANG,   settings["language"]);
	 
	destCfg = File(target + ".jcoDestination");
	# print destCfg
	fos =  FileOutputStream(destCfg, 0);
	connectProperties.store(fos, target);
	fos.close();

Thats the way how i do it. After that you can call.

destination = JCoDestinationManager.getDestination("DEV");

Now i see you have quotes arround you user, i dont have this in my files

user='XYZ'

br,
Roland

Let me emphasize this.

To work around that, create a gateway message handler in your project that calls your test code in your script library. Then, in the designer's script console, you can use system.util.sendRequest() to cause your test script to run in gateway scope.

2 Likes

Thank you so much , its working. we are able to call BAPI.

Looking forward for more suggestions. Thank you