cancel
Showing results for 
Search instead for 
Did you mean: 

Problem In Connection to SAP using JCo3

Former Member
0 Kudos

Hi,

I am new to SAP. I am using SAP JCo3 for connection with SAP. I have written the following code as given in the StepByStepClient example(which comes with the package of SAP JCo3) :

import com.sap.conn.jco.JCoDestination;

import com.sap.conn.jco.JCoDestinationManager;

import com.sap.conn.jco.JCoException;

/**

* basic examples for Java to ABAP communication 

*/

public class StepByStepClient

{

    static String ABAP_AS = "ABAP_AS_WITHOUT_POOL";

    static String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL";

    static String ABAP_MS = "ABAP_MS_WITHOUT_POOL";

    /**

     * This example demonstrates the destination concept introduced with JCO 3.

     * The application does not deal with single connections anymore. Instead

     * it works with logical destinations like ABAP_AS and ABAP_MS which separates

     * the application logic from technical configuration.    

     * @throws JCoException

     */

    public static void step1Connect() throws JCoException

    {

        JCoDestination destination = JCoDestinationManager.getDestination(ABAP_AS);

        System.out.println("Attributes:");

        System.out.println(destination.getAttributes());

        System.out.println();

        destination = JCoDestinationManager.getDestination(ABAP_MS);

        System.out.println("Attributes:");

        System.out.println(destination.getAttributes());

        System.out.println();

    }

    public static void main(String[] args) throws JCoException

    {

        step1Connect();

    }

}

When I run the file following error has occured :

Exception in thread "main" com.sap.conn.jco.JCoException: (102) JCO_ERROR_COMMUNICATION: Connect to SAP gateway failed

Connection parameters: TYPE=A DEST=ABAP_AS_WITHOUT_POOL ASHOST=<IPNumber> SYSNR=00 PCS=1

LOCATION    CPIC (TCP/IP) on local host with Unicode

ERROR       partner 'IP' not reached

TIME        Tue Sep 18 23:09:31 2012

RELEASE     720

COMPONENT   NI (network interface)

VERSION     40

RC          -10

MODULE      nixxi.cpp

LINE        3286

DETAIL      NiPConnect2: IP

SYSTEM CALL connect

ERRNO       10060

ERRNO TEXT  WSAETIMEDOUT: Connection timed out

COUNTER     2

I want to know the following things:

1. What could be the reason for this error?

2. Why it is trying to connect to host 'IP' as i have not specified any property in this file?

3. What I have to do if I want to connect to host 'IP' ?

Message was edited by: Benny Schaich-Lebek I deleted the IP address. Please never publish IP addresses for  security reason.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks Simon and Tobias for your help.

hofmann
Active Contributor
0 Kudos

Take a look at CustomDestinationDataProvider.java to see how to connect to ABAP:

Set server properties:

static Properties getDestinationPropertiesFromUI()

    {

        //adapt parameters in order to configure a valid destination

        Properties connectProperties = new Properties();

        connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "appserver");

        connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,  "00");

        connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "000");

        connectProperties.setProperty(DestinationDataProvider.JCO_USER,   "JCOTESTER");

        connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "JCOTESTERSPASSWORD");

        connectProperties.setProperty(DestinationDataProvider.JCO_LANG,   "en");

        return connectProperties;

    }

There is a inner class

     static class MyDestinationDataProvider implements DestinationDataProvider

for setting the destination + properties

In main() the connection properties are finally set:

     myProvider.changeProperties(destName, getDestinationPropertiesFromUI());

Former Member
0 Kudos

Hi Preeti,

So somewhere in the configuration you must define the logical destination ABAP_AS_WITHOUT_POOL there you will have a chance to specify the target server.

Please take a look at this:

http://help.sap.com/saphelp_nwpi711/helpdata/en/48/874bb4fb0e35e1e10000000a42189c/frameset.htm

Hope this helps you,
Simon