Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

JCo connection

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

Not what you were looking for? View more on this topic or Ask a question