cancel
Showing results for 
Search instead for 
Did you mean: 

JCo connection

Former Member
0 Kudos

Hello!

I want to build a web application which should call RFC Function modules from SAP system. I use SAP Netweaver Developer Studio which provides functionality to generate code for function modules (SAP enterprise connector). To call this function module I need to connect to SAP system first. I decided for JCo (version 2.18 u2013 downloaded from SAP service marketplace). And here is a problem. I use identical configuration like SAP logon and SAP enterprise connector (both works perfectly).

Configuration in SAP Logon and SAP Enterprose Connector:

Application Server: 21.48.170.56

System Number: 00

System ID: MT2

SAP Router String: /H/194.14.124.170/H/

So I chose one of them and let NW developer to generate code. Now I want to connect to SAP system. Here is my source code:


package com.ibs.web.ibsos;

import com.ibs.web.ibsos.rfc.Connector_PortType;
import com.ibs.web.ibsos.rfc.__Ibs__Os_Db_Meldung_Rfc_Input;
import com.ibs.web.ibsos.rfc.__Ibs__Os_Db_Meldung_Rfc_Output;
import com.sap.aii.proxy.framework.core.ApplicationFaultException;
import com.sap.aii.proxy.framework.core.SystemFaultException;
import com.sap.mw.jco.JCO;

public class ConnectionTest {


	public static void main(String[] args) {

		String[][] loginParams = {
			{ "client", "100" }, 				          // SAP client
			{ "userid", "userid" }, 			                          // user id
			{ "passwd", "******" }, 			                          // password
			{ "language", "DE" }, 				          // language
			{ "ashost", "21.48.170.56" }, 		                          // host name
			{ "sysnr", "00" }, 				          // system number
			{ "gwhost", "/H/194.14.124.170/H/" },                                     // gateway host
			{ "gwserv", "sapdp99" } 			          // gateway service | sapdp99 = 3299
		};
		
		try {
			// create client
			JCO.Client client = JCO.createClient(loginParams);
			// connect to SAP system
			client.connect(); 
			// create connector instance
			Connector_PortType connector_PortType = new Connector_PortType();
			// set cliet
			connector_PortType.messageSpecifier.setJcoClient(client); 
			// create input instance
			__Ibs__Os_Db_Meldung_Rfc_Input input = new __Ibs__Os_Db_Meldung_Rfc_Input(); 
			// get output
			__Ibs__Os_Db_Meldung_Rfc_Output output = connector_PortType.__Ibs__Os_Db_Meldung_Rfc(input);
			// disconnect
			client.disconnect(); 
		} catch (SystemFaultException e) {
			e.printStackTrace();
		} catch (ApplicationFaultException e) {
			e.printStackTrace();
		} catch (JCO.Exception e) {
			e.printStackTrace();
		}

	}

}

And I get this error:


com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect to SAP gateway failed
Connect_PM  GWHOST=/H/194.14.124.170/H/, GWSERV=sapdp99, ASHOST=21.48.170.56, SYSNR=00

LOCATION    SAProuter 39.1 (SP3) on 'cscappwie178'
ERROR       cscappwie178: route permission denied (172.30.37.22 to ,
            sapdp99)

TIME        Thu Oct 02 14:48:42 2008
RELEASE     710
COMPONENT   NI (network interface)
VERSION     39
RC          -94
COUNTER     31686

	at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeConnect(Native Method)
	at com.sap.mw.jco.rfc.MiddlewareRFC$Client.connect(MiddlewareRFC.java:1125)
	at com.sap.mw.jco.JCO$Client.connect(JCO.java:3138)
	at com.ibs.web.ibsos.ConnectionTest.main(ConnectionTest.java:30)

Note: 172.30.37.22 is IP of my computer.

I have no Idea why I can get connected to SAP system via SAP Logon and SAP Enterprise Connector, but via JCo not. With the same configuration!!! How can I get Permision denied???

Thanks for your help!

Jozef

Edited by: Jozef Kubov on Oct 2, 2008 3:20 PM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi!!

I have a problem connecting with Jco, My problem is similar to yours.

I have doubt in the parameters.

Thanks,

Here is my source code:

public class llamada {

public static void main(String[] args) throws SystemFaultException, ApplicationFaultException {

JCO.Client jcoclient = JCO.createClient( "100", "MHOYOS", "*****","ES",

"10.1.220.161","01","/H/200.13.228.41/H/","devsap");

jcoclient.connect();

}

}

And the error:

Exception in thread "main" com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect to SAP gateway failed

Connect_PM GWHOST=/H/200.13.228.45/H/, GWSERV=sapgw01, SYSNR=01

LOCATION SapRouter on apolo

ERROR hostname '' unknown

TIME Thu Nov 6 18:40:04 2008

RELEASE 620

COMPONENT NI (network interface)

VERSION 36

RC -90

MODULE nixxi.c

LINE 2209

DETAIL NiIHostToAddr

COUNTER 930

at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeConnect(Native Method)

at com.sap.mw.jco.rfc.MiddlewareRFC$Client.connect(MiddlewareRFC.java:1125)

at com.sap.mw.jco.JCO$Client.connect(JCO.java:3138)

at paquete.llamada.main(llamada.java:23)

Stefan-EA
Contributor
0 Kudos

Here is a [blog|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/10300] [original link is broken] [original link is broken] [original link is broken]; that shows you how to use the destinations services, which will avoid you having to hard code the connection details in the code.

Former Member
0 Kudos

This is how the setting should look like:

String[][] loginParams = {

{ "client", "100" }, // SAP client

{ "user", "userid" }, // user id

{ "passwd", "******" }, // password

{ "lang", "DE" }, // language

{ "ashost", "/H/sap-routerH/sap-sys" }, // host name

{ "sysnr", "00" }, // system number

};

Thanks a lot!

Former Member
0 Kudos

please colse this. i hope u got solution from ur self.