JCO Server implementation questions

Hi experts,
I want to try to create a JCO Server with the JCO 3 library.
I'm kinda lost in all the links I've found since there is still a lot of things from the JCO 2 on the internet and I don't understand everything I'm doing.
Please note that there is already a working Java JCO server with old IBM tools and we need to migrate to JCO 3.
So here are my questions :
What do I have to do exactly in the sm59 transaction ?
Here is what I get in the RSGWLST transaction http://i.imgur.com/IRgAyO8.png http://i.imgur.com/YyfDQbt.png (Loic-PC is my machine so I guess my java jco server is up.) Is everything ok ?
I have followed this link (Java Program for Creating a Server Connection - Components of SAP Communication Technology - SAP Library) to create my java jco server. What exactly are ServerDataProvider.JCO_GWHOST, ServerDataProvider.JCO_GWSERV and above all ServerDataProvider.JCO_PROGID)
How do I testmy Java JCO server ? I understood that I have to call STFC_TRANSACTION in se37 where I put my jco destination (previously set up in sm59 ?) and a string but I have a dump when I'm tying that.
I hope someone can help me, everything is still really blurry to me.
Here is the code I use to try to connect :
    static String SERVER_NAME1 = "JCO_SERVER";
        Properties connectProperties = new Properties();
        connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "");
        connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,  "00");
        connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "500");
        connectProperties.setProperty(DestinationDataProvider.JCO_USER,   "develop2");
        connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "passw0rd");
        connectProperties.setProperty(DestinationDataProvider.JCO_LANG,   "en");
        createDataFile(DESTINATION_NAME1, "jcoDestination", connectProperties);
        connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "3");
        connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT,    "10");
        createDataFile(DESTINATION_NAME2, "jcoDestination", connectProperties);
        Properties servertProperties = new Properties();
        servertProperties.setProperty(ServerDataProvider.JCO_GWHOST, "sapdevdb02");
        servertProperties.setProperty(ServerDataProvider.JCO_GWSERV, "sapgw00");
        servertProperties.setProperty(ServerDataProvider.JCO_PROGID, "JCOServer");
        servertProperties.setProperty(ServerDataProvider.JCO_REP_DEST, "ABAP_AS_WITH_POOL");
        servertProperties.setProperty(ServerDataProvider.JCO_CONNECTION_COUNT, "2");
        createDataFile(SERVER_NAME1, "jcoServer", servertProperties);

Hi Loic.
The properties GWHost is Gateway Host and GWSERV stands for Gateway Server.
Please look at this link to get more details:
Possible Parameters (SAP Library - Components of SAP Communication Technology)
Could you please put your full code for this class?
I'm saying this because the code you have wrote only creates the propreties file that JCO uses to configure the server but you have to run your server through the main statement.
You have to do something like that on your StfcConnectionHandler class.
public static void main(String[] args) {
See my example:
StfcConnectionHandler class--------------------
package main;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.server.DefaultServerHandlerFactory;
import com.sap.conn.jco.server.JCoServer;
import com.sap.conn.jco.server.JCoServerContext;
import com.sap.conn.jco.server.JCoServerFactory;
import com.sap.conn.jco.server.JCoServerFunctionHandler;
public class StfcConnectionHandler implements JCoServerFunctionHandler {
  private static final String SERVER_NAME1 = "YOUR_SERVER_NAME";
  public void handleRequest(JCoServerContext serverCtx, JCoFunction function) {
  System.out.println("call              : " + function.getName());
  .println("ConnectionId      : " + serverCtx.getConnectionID());
  System.out.println("SessionId         : " + serverCtx.getSessionID());
  System.out.println("TID               : " + serverCtx.getTID());
  System.out.println("repository name   : "
  + serverCtx.getRepository().getName());
  .println("is in transaction : " + serverCtx.isInTransaction());
  System.out.println("is stateful       : "
  + serverCtx.isStatefulSession());
  System.out.println("gwhost: " + serverCtx.getServer().getGatewayHost());
  System.out.println("gwserv: "
  + serverCtx.getServer().getGatewayService());
  System.out.println("progid: " + serverCtx.getServer().getProgramID());
  System.out.println("attributes  : ");
  System.out.println("req text: "
  + function.getImportParameterList().getString("REQUTEXT"));
  function.getExportParameterList().setValue("RESPTEXT", "Hello World");
  static void step1SimpleServer() {
  JCoServer server;
  try {
  server = JCoServerFactory.getServer(SERVER_NAME1);
  } catch (JCoException ex) {
  throw new RuntimeException("Unable to create the server "
  + SERVER_NAME1 + ", because of " + ex.getMessage(), ex);
  JCoServerFunctionHandler stfcConnectionHandler = new StfcConnectionHandler();
  DefaultServerHandlerFactory.FunctionHandlerFactory factory = new DefaultServerHandlerFactory.FunctionHandlerFactory();
  factory.registerHandler("STFC_CONNECTION", stfcConnectionHandler);
  System.out.println("The program can be stopped using <ctrl>+<c>");
  public static void main(String[] args) {
StepByStepServer class
package main;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Properties;
import com.sap.conn.jco.ext.DestinationDataProvider;
import com.sap.conn.jco.ext.ServerDataProvider;
public class StepByStepServer
    static String SERVER_NAME1 = "SERVER";
        Properties connectProperties = new Properties();
        connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "ls4065");
        connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,  "85");
        connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "800");
        connectProperties.setProperty(DestinationDataProvider.JCO_USER,   "farber");
        connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "laska");
        connectProperties.setProperty(DestinationDataProvider.JCO_LANG,   "en");
        createDataFile(DESTINATION_NAME1, "jcoDestination", connectProperties);
        connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "3");
        connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT,    "10");
        createDataFile(DESTINATION_NAME2, "jcoDestination", connectProperties);
        Properties servertProperties = new Properties();
        servertProperties.setProperty(ServerDataProvider.JCO_GWHOST, "binmain");
        servertProperties.setProperty(ServerDataProvider.JCO_GWSERV, "sapgw53");
        servertProperties.setProperty(ServerDataProvider.JCO_PROGID, "JCO_SERVER");
        servertProperties.setProperty(ServerDataProvider.JCO_REP_DEST, "ABAP_AS_WITH_POOL");
        servertProperties.setProperty(ServerDataProvider.JCO_CONNECTION_COUNT, "2");
        createDataFile(SERVER_NAME1, "jcoServer", servertProperties);
    static void createDataFile(String name, String suffix, Properties properties)
        File cfg = new File(name+"."+suffix);
                FileOutputStream fos = new FileOutputStream(cfg, false);
                properties.store(fos, "for tests only !");
            catch (Exception e)
                throw new RuntimeException("Unable to create the destination file " + cfg.getName(), e);

Similar Messages

  • JCo server programming, properties and connection settings

    Greetings, SAP professionals.
    The reason I come to this forum is that I'm hoping to gain some insights into the use of the SAP Java Connector (JCo). I am a developer who was tasked with making a new component for a systems integration application. As is typical of integration software, our app can link together various different systems using a variety of protocols, as well as providing the means to apply business logic on messages passed from one location to another. We already have a connector acting as an SAP client which was implemented using JCo. Now, we were asked to develop a new component: a server capable of accepting RFCs from a remote SAP system acting as client. The server is to be created using the JCo classes, so basically an extension of JCo.Server, with some logic for creating function templates from configuration files.
    However, while I'm understanding the structure of the Java API, it's not entirely clear to me just what the classes do. I've found the JavaDoc for JCo to be mostly descriptive of the interface of classes and methods, but not really explaining what these achieve, or how. So I'm hoping to be set straight, as I fear I'm kind of misunderstanding the functionality of JCo... Being mainly an integrations developer, I unfortunately often have to settle for gaining a superficial knowledge of a variety of systems to quickly interface with them, so I don't have any prior knowledge of SAP but still need to be able to implement something with JCo without too much delay.
    The most important question I have is this: when a JCO.Server implementation is started, does it act as a fully standalone component capable of receiving calls, or does it merely act as a sort of listener for some main SAP system? I'm not talking about a reliability on the two .dll files (or .so for Linux) that are required for the use of JCo, I just wish to know if the JCo package is entirely self-sufficient for server functionality or if it is intended to be linked to some SAP system.
    A second problem I have is that the parameters passed to various constructors aren't clear to me... I'm not familiar with SAP terminology, nor have I worked with any client apps that make use of an SAP system.
    The meaning of client strings, gwhost, gwservice, ashost, system IDs and program IDs mostly elude me, especially when it comes to knowing what client parameters must match what server parameters.
    In order to familiarize myself with the classes, I've tried playing around with them a bit trying to create a small test app that first starts a JCO.Server instance, then tries to make a remote function call to it with a JCO.Client (within the same class, for simplicity and debugging purposes). I was wondering if this actually makes sense... Would a JCo client be capable of connecting to a JCo server, all running purely in Java, or is that nonsense?
    To eliminate some common troubleshooting options, I'll quicly describe the steps I've taken:
    Both librfc32.dll and sapjcorfc.dll were placed in the Windows system32 folder. Maybe only librfd32 needs to be placed there, but I copied both anyway to make sure.
    The directory containing the jar file and both dll files is included in my environment path variable.
    I've added a line to the C:\Windows\system32\drivers\etc\services file as follows:
    sapgw00          3300/tcp                           #SAP System Gateway Port
    I've opened port 3300 in my Windows firewall. In fact, I also tested with the firewall completely turned off.
    However, I do not manage to get my test class to work. I've tried ports 3300, 3200 and 3600. I've tried various permutations of the client and server properties. I've tried removing the line from the services file, which would prompt the client to state upon connecting that the service "sapgw00" is unknown. When I add it back in, the error changes to "partner not reached", so it is definitely picking something up.
    The server itself starts just fine, but connecting through a client doesn't work. My class source code is posted below. Maybe what I'm trying to do doesn't make any sense, but at the moment it's my best guess.
    I realize this is a pretty long post and the class, while not exactly big, also implies a bit of reading of its own. But if anyone could give me any answers that are new to me, I'd be hugely grateful. Right now I'm kind of stuck, and just setting up the service and letting our customer test on it is a somewhat slow approach that can't match developing and testing on one and the same host.
    Preliminary thanks to everyone who took the effort to read this.
    //Start of code
    import java.util.Properties;
    import com.sap.mw.jco.IFunctionTemplate;
    import com.sap.mw.jco.IMetaData;
    import com.sap.mw.jco.IRepository;
    import com.sap.mw.jco.JCO;
    public class Test {
         public static void main(String[] args) {
              Test test = new Test();
              ServerThread serverThread = test.new ServerThread();
              while(!serverThread.isReady) {
                   try {
                   } catch(final InterruptedException i) {
                        System.out.println("Rudely awakened");
              try {
    //               JCO.Function func = getSampleFunction(test, "STAY");
    //               serverThread.server.handleRequest(func);
    //               System.out.println(func.getExportParameterList().toXML());
    //               func = getSampleFunction(test, "STOP");
    //               serverThread.server.handleRequest(func);
    //               System.out.println(func.getExportParameterList().toXML());
                   final Properties clientProps = getClientProps();
                   JCO.Client client = JCO.createClient(clientProps);
                   IRepository rep = JCO.createRepository("1", client);
                   IFunctionTemplate templ = rep.getFunctionTemplate("TEST_FUNC");
                   JCO.Function function = templ.getFunction();
                   function.getImportParameterList().setValue("STAY", "FIELD1");
                   JCO.Function function2 = templ.getFunction();
                   function2.getImportParameterList().setValue("STOP", "FIELD1");
              } catch(final Exception e) {
                   while(serverThread.isAlive) {
                        try {
                        } catch(final InterruptedException i) {
                             System.out.println("Rudely awakened");
              } finally {
         private static Properties getClientProps() {
              final Properties props = new Properties();
              props.setProperty("jco.client.client", "100");
              props.setProperty("jco.client.user", "");
              props.setProperty("jco.client.passwd", "");
              props.setProperty("jco.client.lang", "");
              props.setProperty("jco.client.sysnr", "00");
              props.setProperty("jco.client.ashost", "/H/localhost/S/sapgw00");
              props.setProperty("jco.client.gwhost", "localhost");
              props.setProperty("jco.client.gwserv", "sapgw00");
              return props;
         public class ServerThread extends Thread {
              public void run() {
                   isAlive = true;
                   IRepository repos = new TestRepository("testrep");
                   server = new TestServer(repos);
                   System.out.println("Server successfully started");
                   isReady = true;
                   while(!stop) {
                        try {
                        } catch(final InterruptedException i) {
                             System.out.println("Wouldn't let me sleep...");
                        stop = server.stopRequested;
                   isAlive = false;
                   System.out.println("Server successfully stopped");
              public void requestStop() {
              public TestServer server;
              public boolean isReady = false;
              public boolean isAlive = false;
         public class TestServer extends JCO.Server {
              public TestServer(IRepository rep) {
                   super("localhost", "sapgw00", "PROGID", rep);
              public void handleRequest(JCO.Function fct) {
                   try {
                        JCO.ParameterList importParams = fct.getImportParameterList();
                        final String importXML = importParams.toXML();
                        System.out.println("XML representation of import parameters: ");
                        final String input = importParams.getString("FIELD1");
                        System.out.println("FIELD1 value: " + input);
                        JCO.ParameterList exportParams = fct.getExportParameterList();
                        if(input.equals("STOP")) {
                             stopRequested = true;
                   catch(JCO.AbapException ex) {
                        throw ex;
                   catch(Throwable t) {
                        throw new JCO.AbapException("SYSTEM_FAILURE", t.getMessage());
              public boolean checkAuthorization(String functionName, int authorMode, String partner, byte[] key) {
                   System.out.println(functionName + " " + partner);
                   return true;
              public void requestStop() {
                   stopRequested = true;
              public boolean stopRequested = false;
         public class TestRepository extends JCO.BasicRepository implements IRepository {
              public TestRepository(String name) {
         public static IMetaData getFunctionInterface() {
              JCO.MetaData metaData = new JCO.MetaData("TEST_FUNC");
              metaData.addInfo("FIELD1", IMetaData.TYPE_STRING, 4);
              metaData.setFlags(0, IMetaData.IMPORT_PARAMETER);
              metaData.addInfo("FIELDX", IMetaData.TYPE_STRING, 8);
              metaData.setFlags(1, IMetaData.IMPORT_PARAMETER & IMetaData.OPTIONAL_PARAMETER);
              metaData.addInfo("FIELD2", IMetaData.TYPE_STRING, 2);
              metaData.setFlags(2, IMetaData.EXPORT_PARAMETER);
              return metaData;
         public static JCO.Function getSampleFunction(Test test, String s) {
              TestRepository testRep = test.new TestRepository("testrepository");
              JCO.Function func = testRep.getFunctionTemplate("TEST_FUNC").getFunction();
              func.getImportParameterList().setValue(s, "FIELD1");
              return func;
         private static boolean stop = false;

    If I understood you correctly, you want to provide a "service" that can be called from SAP. To provide this service you've chosen to implement an (external) RFC server program via JCo. One common method for RFC server programs is to register in SAP on the gateway - you do this by supplying the three parameters
    <li><b>jco.server.gwhost</b> -  SAP gateway host on which the server should be registered (so this would be the server name or IP address of the SAP gateway; localhost is only correct, if your RFC server program runs on the same server as the SAP gateway)</li>
    <li><b>jco.server.gwserv</b>  - Gateway service, i.e. the port on which a registration can be done</li>
    <li><b>jco.server.progid</b> - Program ID under which your RFC server program can be reached (free, made-up case sensitive name, that should represent the service your RFC server is providing)</li>
    So essentially you're creating a listener, that is registered in SAP and waits for any invocations. Within SAP they will define a <i>RFC destination</i>, which basically represents a TCP/IP connection pointing to the SAP gateway where you registered with the given program ID. If you want more details, check the SAP help pages for <a target="_blank" href="http://help.sap.com/saphelp_nw04/helpdata/en/22/04262b488911d189490000e829fbbd/content.htm">RFC destinations</a> (you're looking for destination type <b>T</b>, see explanations <a target="_blank" href="http://help.sap.com/saphelp_nw04/helpdata/en/22/042652488911d189490000e829fbbd/content.htm">here</a>).
    Usually gateway host and service (port) are given to you by the SAP basis folks and you tell them which program ID you're using. They will then enter those parameters in an RFC destination of type <b>T</b> in SAP. So no need for any of the client parameters you've mentioned. Although, I'd like to repeat, it's usually handy to also have SAP logon parameters maintained on your RFC server program, so that you can utilize the repository data from SAP (might be irrelevant in your case).
    Hope this clarifies it a bit...

  • ABAP process hangs when calling a jCO Server J2EE-available RFC

    Hi there
    Here's the scenario:
    We have deployed a jCO server under the SAP WAS. This jCO server implements two functions. They are both called from ABAP process through RFC. We are using the same RFC destination for both
    First function is defined with import/export parameters and the second one only operates with a TABLE parameter.
    Incidentally, these functions are captured by the jCO server, which calls an IBM MQ server
    First function works fine. Second function hangs and there is not even a timeout so the ABAP process (run on foreground) can stay forever.
    The interesting part is that the same application works really fine when called from a Tomcat using a standalon instance of the jCO.
    Additional info:
    We have noticed that some time after the second function gets called, there are five dumps on the system (the same amount of servers we make available). These are CALL_FUNCTION_SIGNON_REJECTED.
    The fun part of the dumps is that the user making the RFC call is a different user that the one we use for the jCO connection, and the client number is '000', instead of the '728' we are using for the connection. Somehow they seem related but we do not know how yet:
    Short text
        You are not authorized to logon to the target system (error code 1).
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "SAPMSSY1" had to be terminated because it has
        come across a statement that unfortunately cannot be executed.
    Error analysis
        RFC (Remote Function Call) sent with invalid
        user ID "%_LOG01% " or client 000.
        User "ARINSO " under client 001 from system "SMD " has tried to carry out an
        call under the user ID "%_LOG01% " and client 000 (Note: For releases < 4.0,
         information on caller and caller system do not exist.).
    Call Program........."SAPLSMSY_ACTUALIZE_DATA"
    Function Module..... "SCSM_SYSTEM_LIST"
    Call Destination.... "SM_ET7CLNT000_READ"
    Source Server....... "sapwasmd_SMD_10"
    Source IP Address... ""
    Termination occurred in the ABAP program "SAPMSSY1" - in
        The main program was "SAPMSSY1 ".
        In the source code you have the termination point in line 67
        of the (Include) program "SAPMSSY1".
    Any tip or suggestion on where to look at is more than welcome
    Thanks in advance,

    And this is the content of the defaultTrace.0.trc log from the WAS
    lain###sap.com caf/um/relgroups/imp MAIN_NW701P03_C 2846629#
    isterNode</Kernel/System Threads Pool/WaitingTasksCount>: com.sap.engine.library.monitor.
    mapping.ccms.CcmsConnectorException: 2100850: Invalid configuration group for node'/Kerne
    l/System Threads Pool/WaitingTasksCount' (MANAGERS.SThreadPool.WaitingInRequestQueueCount
    , max. 40 characters)#
    isterNode</Kernel/System Threads Pool/WaitingTasksQueueOverflow>: com.sap.engine.library.
    monitor.mapping.ccms.CcmsConnectorException: 2100850: Invalid configuration group for nod
    e'/Kernel/System Threads Pool/WaitingTasksQueueOverflow' (MANAGERS.SThreadPool.Waiting4Fr
    eeReqQueueSlotCount, max. 40 characters)#
    isterNode</Kernel/Application Threads Pool/WaitingTasksCount>: com.sap.engine.library.mon
    itor.mapping.ccms.CcmsConnectorException: 2100850: Invalid configuration group for node'/
    Kernel/Application Threads Pool/WaitingTasksCount' (MANAGERS.AThreadPool.WaitingInRequest
    QueueCount, max. 40 characters)#
    isterNode</Kernel/Application Threads Pool/WaitingTasksQueueOverflow>: com.sap.engine.lib
    rary.monitor.mapping.ccms.CcmsConnectorException: 2100850: Invalid configuration group fo
    r node'/Kernel/Application Threads Pool/WaitingTasksQueueOverflow' (MANAGERS.AThreadPool.
    Waiting4FreeReqQueueSlotCount, max. 40 characters)#
    valtran_validator#System.err#Guest#0##ET7#MIGUELGU                        #4A240FF606CD5E
    p]##0#0#Error##Plain###com.sap.mw.jco.JCO$AbapException: (126) 1: Array index out of rang
    e: 48#
    valtran_validator#System.err#Guest#0##ET7#MIGUELGU                        #4A240FF606CD5E
    p]##0#0#Error##Plain### at com.efh.jco.valtran.sap.ValtranRequestHandler.serverExceptionO
    valtran_validator#System.err#Guest#0##ET7#MIGUELGU                        #4A240FF606CD5E
    p]##0#0#Error##Plain### at com.sap.mw.jco.JCO.fireServerExceptionOccurred(JCO.java:880)#
    valtran_validator#System.err#Guest#0##ET7#MIGUELGU                        #4A240FF606CD5E
    p]##0#0#Error##Plain### at com.sap.mw.jco.JCO$Server.listen(JCO.java:8187)#
    valtran_validator#System.err#Guest#0##ET7#MIGUELGU                        #4A240FF606CD5E
    p]##0#0#Error##Plain### at com.sap.mw.jco.JCO$Server.work(JCO.java:8303)#
    valtran_validator#System.err#Guest#0##ET7#MIGUELGU                        #4A240FF606CD5E
    p]##0#0#Error##Plain### at com.sap.mw.jco.JCO$Server.loop(JCO.java:8250)#
    valtran_validator#System.err#Guest#0##ET7#MIGUELGU                        #4A240FF606CD5E
    p]##0#0#Error##Plain### at com.sap.mw.jco.JCO$Server.run(JCO.java:8166)#
    valtran_validator#System.err#Guest#0##ET7#MIGUELGU                        #4A240FF606CD5E
    p]##0#0#Error##Plain### at java.lang.Thread.run(Thread.java:770)#

  • JCo Server High Availability

    How can I make the JCo server implement "High Availability" functionality. The SAP Server which the makes calls to the JCo Server is HA-aware. So if there is a failover, the SAP Server switches over to the other instance but the JCo server keeps sending the message "Server unavailable". Is there a solution for this problem.

    Single Appliance not necessarily means Single Point of Failure, an appliance with HW Redundancy could handle failure and provide High Availability, if only configured well.
    Does Symantec BrightMail Appliance provide such redundancy configuration?
    You will have to ask their support or in a Symantec Forum.
    Twitter!: Please Note: My Posts are provided “AS IS” without warranty of any kind, either expressed or implied.

  • Question, in a client server implemention

    Question, in a client server implemention using only basic sockets and datagrams, what happens if a method is being called at the server side while the same method is already being called/running for another client?
    Client 1 calls Method 1 at Server Side. Method 1 runs.
    Client 2 calls Method 1 at Server Side. Method 1 is still running for Client 1. Does it create another Thread and runs for Client 2? Or do I have to implement a seperate Thread for each Client myself?

    Don't want to start a new thread so might as well ask this here,
    Is there a way to pass or at least update the value of a variable from the outside into a Thread that is running? And this value needs to be seen and be the same for all Threads.
    I am thinking of creating new a class that to hold the value I want to update, and passing an object of the class in to the Threads before they runs. Since objects hold reference to the location of the actual object or something like that; people always get worked up over this if I phrase this incorrectly, but I think I got the point across, so that's okay. If I change the value of the object at runtime in the main method, like assign it with a new value according to user input. All the Threads will get the new value right?
    Something like that.
    public class valueToUpdate {
    String value;
    public valueToUpdate(String value) {
    this.value = value;
    public String getValue() {  
    return value;  
    public class Main {  
    public static void main(String[] args) {  
    String str = "abc";  
    valueToUpdate vTU = new valueToUpdate(str);  
    ThreadClass tc1 = new ThreadClass(vTU);  
    Thread thread1 = new Thread(tc1).start();  
    ThreadClass tc2 = new ThreadClass(vTU);  
    Thread thread2 = new Thread(tc2).start();   
    public class ThreadClass implements Runnable {  
    valueToUpdate vTU;  
    public ThreadClass(valueToUpdate vTU) {  
    this.valueToUpdate = valueToUpdate;  
    public void run() {  
    }Okay, something like that. I know I need to add in a TimerTask for ThreadClass too for it to run for a certain period. But if I were to ask for user input at the main method while the TimerTask in running, and I change the value of vTU, will the output for both Threads be changed to the value of the user input?
    Or is there a better way to do it?

  • RFC call failed: JCO.Server could not find server function 'SET_SLD_DATA'

    Hi, All
    the system is PI 7.0 EHP1 oraclei Win2003 server, I configured SLD but I run RZ70, having error "RFC call failed: JCO.Server could not find server function 'SET_SLD_DATA' ". I know there are lot of tread about this error, but none of themsolve my problem. all JCO, RFC connections and SDL DATA supplier(VA) seem OK. error message in SM21 is "Could not send SLD data"
    detail from SM21
    The system could not send the data that has been collected automatical
    for the System Landscape Directory (SLD). Check whether the gateway
    configured in transaction RZ70 has been started and whether the SLD
    bridge has been registered with this gateway.
    You can use transaction SM59 to check this in the sending system for t
    implemented RFC destinations. The RFC destinations have the standard
    names "SLD_UC" for Unicode sending systems and "SLD_NUC" for non-Unico
    sending systems. If a different RFC destination has been entered in
    RZ70, check this destination instead.
    You can use the Gateway Monitor to check the target gateways. In ABAP
    systems, this monitor is started with transaction SMGW, or you can use
    the external SAP program "gwmon". Check whether the specified gateway
    has an active registration.
    OF COURSE I checked  RFC of  SLD_UC and SMGW
    any different ideas

    Please check the following notes are implemented
    Note 906454                           
    Note 907729
    You may be aware but if you are not --->RZ70 creates the required SLD* RFCs during runtime - therefore if you have defined these RFCs manually first using the same namespace you can get RFC conflicts which result in a failed submission    
    Please also check the user in the RFC is known to both systems and has required authorization to write to SLD
    Generally with SLD you have to install or select a suitable gateway to handle incoming data supply traffic
    Also the gateway you are using has be known to SLD and reflected in RZ70 - i.e these defintions have to be the same
    It is also recommended to delete all references to SLD_* RFCs in data supplier and target SLD
    after a failed submission attempt to allow RZ70 to recreate these consistently once the above has been checked
    Best wishes

  • JCo Server Load Balancing

    We have created a JCo Server interface using RFC modules in SAP to communicate with an external web based system.  The SAP system calls the external application via tRFC and qRFC as needed from the business transaction.  We have achieved high throughput by clustering our external web application server, putting a load balancer in front of that web application, and finally creating multiple JCo Server instances within own JVMs (currently 6 instances with 5 servers each).  The JCo Server is registered to the central gateway of the SAP system using gwhost, gwserv, and progid.  With this setup we have successfully performed up to 50,000 transactions an hour.
    My understanding is that the SAP gateway will act as a load balancer on the SAP side.  Is this right or should we consider to install a hardware load balancer "in front" of the SAP gateway and try to map this to the message server instead?  Or concern is that our JCo Server process will "flood" the central gateway and take all resources away form the SAP system.  Unfortunately the JCo Server class doesn't allow to connect to any other resource on the SAP system then the central gateway.
    Any suggestions or real live examples are appreciated.

    Hi Stefan
    We are doing a similar project wherein we are calling a middleware server based on the JCO.Server from SAP.
    You did say that you have achieved a throughput of 50000 transactions and we are interested in knowing how ?.
    Could you briefly tell use how you achieved it. In our case we have one instance of the JCO.Server working on the JVM.
    Here is what we did .
    We tried to start two instances of the middle ware server on the same JVM on the same BOX and register it with the gateway . This dint work .
    We were successfull in starting two instances of the middleware server from two different JVM on two different boxes and registering it at the gateway under the same id.
    This we know will work as the gateway will use its load balancing to distribute load between the two instances.
    But we are interested in knowing how we can start more then one server instance on a given JVM.
    Our questions are
    It we have threading in our middleware server, we believe it will not help as if the SAP gateway server has opened an connection with one instance of the middleware server. It is not possible for it to open another one...till the first one is complete. Hence threading within the middleware server is redundant.
    Your thoughts and comments are appreciated.

  • Jco.server.max_startup_delay

    SAP Note 730870 say:
    Q 25: A RFC sender channel is registered at a SAP Gateway which is shutdown. Does the RFC sender channel automatically reconnect to the SAP Gateway after it is available again?
    A: The SAP Gateway is shutdown due to e.g. offline backup of the R/3 database while a RFC-Adapter sender channel is registering at this SAP Gateway. After restarting the SAP Gateway, the RFC sender channel does not seem to automatically perform a reconnect.
    Actually the RFC sender channel will try to reconnect to the SAP Gateway. If this reconnect fails, the next reconnect attempt is made after a waiting period of 1 second. If the next reconnect fails also, the waiting period is doubled and so on. This will lead to a reconnect timing of 1, 2, 4, 8, ..., 3600 seconds. Saving recources is the aim of this technique.
    If not configured, the maximum waiting time is defined in the middleware layer of SAP JCO, which is 3600 seconds. But this maximum time can be configured for each RFC sender channel in the XI Integration Directory. Open the Advanced Mode for the RFC Server Parameter.
    Before SP 12: Add a line to the table and use 'jco.server.max_startup_delay' as name and the maximum number of seconds to wait between reconnect attempts as value.
    Since SP 12: Enter the maximum number of seconds to wait between reconnect attempts in the field Maximum Reconnect Delay.
    My question:
    Where to find the parameter jco.server.max_startup_delay?
    Dirk-Jan Kloezeman

    When you are connected to the J2EE Engine choose the tab 'Cluster' and open the appropriate server node in the tree. Then open the 'Services' node. There you can see the entry 'SAP XI Adapter: RFC'.
    In this you will find this parameter.
    Source - restart the RFC Adapter - visual admin

  • How can I change a JCo Server retry interval?

    Hi all,
    I have a question regarding the interval of connection retry.
    If my JCo server has a exception, because SAP Server is down, I get following error: Server startup failed. Will try next startup in 1 second.
    Then in 2 seconds, 4 seconds ..... 1024 seconds.
    How can I change this parameter, so the server should try every 60 seconds?
    Any ideas?
    Thanks in advance.

    Ok, I found a solution:
    JCo.Server has a parameter: jco.server.max_startup_delay

  • JCo Server - ABAP to NWJ2EE - Metadata Access

    Hi Friends,
    we are here in a project, which also deals to fetch data from an external non ABAP system. The calling system is a 4.6C. We therefore use the JCo server service (registered RFC connection), which can be called by the 4.6C system. Basicly it works, but we discovered, that currently we get a single point of failure, because we have to provide repository information (connection information) within the visual admin.
    The help page
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/b0/46e13d82fcfb34e10000000a114084/frameset.htm">SAP JCo Server Programming</a> and its examples, would lead us to provide connection properties, e.g. within the coding. Therefore, within visual admin, section "JCo RFC Provider", JNDI name, program ID and connection properties are maintained. The J2EE application therefore use those predefined entries. When starting the first request to JCo server, metadata are being read from repository, which here must be the calling system (our 4.6C system). Within the repository section, you can only provide dedicated application server login information, not e.g. a load balanced one. Thus this is for reasons of high availability, a single point of failure. An ABAP instance itself is not HA required, because you can use multiple of them. The message service itself but is HA required.
    Now after this long explanation my question:
    Are we on the right way, using e.g. visual admin to define the registered server programs, etc - or is there a more integrated, flexible integration possible?
    Perhaps, we need only the correct entry point of documentation or workshops, to direct our project developers to the right way.
    All information I found about higher integration was only for Web Dynpro - and therefore for JCo client integration. But this is not our scenario.
    thanks a lot in advance for your replies,
    reiner leibig

    You might benefit by reading the JCO pdf delivered with the jco download from sapservice.com....(free)....
    Usually it is easier to define the structure and the function interface as an SAP function even if there is no body (abap to java). This means that the JCO will read correctly all the metainformation about the function. You then call the function as an RFC specifying the host...
    Have fun...
    In your case I would read carefully the example (getting the company code info etc...)
    It shows how to manipulate the table returned by ABAP...

  • JCO Server Multithreading

    I need to develop a JCO Server that should handle multiple requests and then I need to start multiple instances of the listeners.
    I would like a sample code for it.

    Many thanks,
    it is very helpful.
    If I got it,, then I can start many servers that use the same program ID ? As stated below:
    for(int i = 0; I < serverConnections.length; i++) {
               serverConnections <i> = new MyFirstServer
                                 ("gwhost",  //gateway host, often the same as host
                                  "sapgw00", //gateway service, generally sapgw<SYSNR>+
                                  "JCOSERVER01", // corresponds to program ID defined in SM59
               serverConnections <i>.start();
    Next question is probably more a hint request:
    when I need to shutdown the servers then I need to invoke the stopServers method. How do I invoke this method ?

  • JCO.Server within Tomcat problem

    I have implemented a JCO Server as a servlet and it is working just fine. However, it refuses to allow other servlets to connect to SAP. It grabs a hold of sapjcorfc.dll and will not let go. So that when I run a servlet that needs to call a BAPI I get the following error message:
    java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'
    JCO.nativeInit(): Could not initialize dynamic link library sapjcorfc [Native Library C:\WINDOWS\system32\sapjcorfc.dll already loaded in another classloader]. java.library.path [C:\Program Files\Java\jdk1.5.0_10\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Java\jdk1.5.0_10\bin]
    Anyone have any idea how I can tell the JCO server not to be so selfish. I tried the JCO Library 2.0.9 and 2.1.8 with same results. This is obviously running on Windows, XP variety. Tomcat 5.5 and Java 1.5.
    Thank you in advance.

    > Hi Rudy,
    > You are a little bit off topic here,
    Sorry <blush> I thought I might be, but I was getting desperate. I posted it in the Java Programming but didn't get much there.
    > anyway please check
    > <a href="/thread/2 [original link is broken]
    > 61626">this</a> thread and especially the two SAP
    > notes mentioned there.
    Thank you. This hint is what I was looking for. I was hoping to be able to get to it today, but I guess it'll have to wait till Monday. In the meantime I found another solution in the OSS notes yesterday. It seem as though the classloader for the sapjcorfc.dll will look for it in the same directory as sapjco.jar first. So I deleted it from the system32 folder and copied it into WEB-INF\lib folder of each project and voila it worked. Although I still want to figure out what this solution is as well.
    > HTH!
    > -Vladimir
    Spasibo Volodya.

  • JCo Server Shutdown

    I have implemented a JCo Server using Example 5 in Jco Documentation.
    The Server shuts down automatically every other day with no dumps leading no trails on how to debug.when we restart, it runs just fine.
    my hunch is that the threads are not properly handled or not releasing the memory, i m not sure.
    Does any one had similar problem or any clues ?

    I also encountered  a  JCO Server problem which likes your problem above when SAP R/3 call java function.
    The SAP R/3 is 4.6c, the JCo package version is 2.0.7.
    In my java program, I start a Jco server and register that Jco server in R/3 sm59. In sm59 I register that connection as a TCP/IP connection.
    In the RZ11, I get the gateway information. 
    My java program is a servlet program, which is running on the WAS640. The program is referred to JCO example 5. I attach the original code in the attachment.
    When I start the Jco server, I get successful connection information in sm59. At that time, the ABAP program can call java program successfully.
    But unluckily I find that link is not stable. Maybe after an hour or several hours, when I run the ABAP program again, RFC error message will popup. At that time I test the connection in sm59, an error message will show “the connection is not registered”. Also in SMGW I can’t find the java rfc connection. Then, I have to restart the jco server, establish a new rfc connection.
    I don’t know what happen. I think maybe it is my program problem(I search the JCO help and try to find a function setting the timeout. But I don’t find any). Maybe there is something to do with basis (I don’t know whether there is a timeout configuration in r/3 or there is a background job will clean up the java connection).
    Would you please give me some advices. I really don’t know how to fix that problem. Thank you for your help.

  • How to deploy a JCO Server????

    Hello Experts!
    I have written a JCO Server by using the Netweaver Developer Studio. Now I want to deploy this JCO Server on our SAP XI Server. The aim of this should be to create a connection between ABAP and JAVA to send data from JAVA to ABAP.
    The RFC connection already exists and is working. What I don't know is how to deploy my JCO Server and how to start this JCO Server from our XI Server. I hope anybody could help me.
    Thanks in advance!!!
    Greetings Alexander
    Here is the source code of my JCO Server:
    public class JCOServer implements JCO.ServerExceptionListener, JCO.ServerStateChangedListener {
      static public class Repository extends JCO.BasicRepository implements IRepository {
        public Repository(String name)
      protected static IRepository repository;
      static {
        repository = new Repository("TestRepository");
        JCO.MetaData fmeta = new JCO.MetaData("ZEJB_TEST_ZUGRIFF");
        fmeta.addInfo("REQUTEXT", JCO.TYPE_CHAR, 255,   0,  0, JCO.IMPORT_PARAMETER, null);
        fmeta.addInfo("ECHOTEXT", JCO.TYPE_CHAR, 255,   0,  0, JCO.EXPORT_PARAMETER, null);
        fmeta.addInfo("RESPTEXT", JCO.TYPE_CHAR, 255,   0,  0, JCO.EXPORT_PARAMETER, null);
      static public class Server extends JCO.Server {
        public Server(String gwhost, String gwserv, String progid, boolean isUnicode, IRepository repository)
           this.setProperty("jco.server.unicode", isUnicode?"1":"0");
        protected void handleRequest(JCO.Function function)
          JCO.ParameterList input  = function.getImportParameterList();
          JCO.ParameterList output = function.getExportParameterList();
          JCO.ParameterList tables = function.getTableParameterList();
          System.out.println("handleRequest(" + function.getName() + ")");
          System.out.println("Anfrage vom SAP-Server: " + input.getString("REQUTEXT"));
          if (function.getName().equals("ZEJB_TEST_ZUGRIFF")) {
            output.setValue("Das ist eine Antwort von JCOServer","RESPTEXT");
       JCO.Server srv[] = new JCO.Server[1];
      public JCOServer()
      public void startServers()
        srv[0] = new Server("vxi1","sapgw00","BEAN",true,repository);
        for (int i = 0; i < srv.length; i++) {
    try {
    catch (Exception ex) {
    System.out.println("Konnte Server nicht starten: " + srv.getProgID() + ":
    " + ex);
      public void serverExceptionOccurred(JCO.Server server, Exception ex)
        System.out.println("Ausnahme in Server " + server.getProgID() + ":
    " + ex);
      public void serverStateChangeOccurred(JCO.Server server, int old_state, int new_state)
        System.out.print("Server " + server.getProgID() + " hat den Status geändert von [");
        if ((old_state & JCO.STATE_STOPPED    ) != 0) System.out.print(" GESTOPPT ");
        if ((old_state & JCO.STATE_STARTED    ) != 0) System.out.print(" GESTARTED ");
        if ((old_state & JCO.STATE_LISTENING  ) != 0) System.out.print(" HORCHEN ");
        if ((old_state & JCO.STATE_TRANSACTION) != 0) System.out.print(" TRANSAKTION ");
        if ((old_state & JCO.STATE_BUSY       ) != 0) System.out.print(" BESCHÄFTIGT ");
        System.out.print("] nach [");
        if ((new_state & JCO.STATE_STOPPED    ) != 0) System.out.print(" GESTOPPT ");
        if ((new_state & JCO.STATE_STARTED    ) != 0) System.out.print(" GESTARTED ");
        if ((new_state & JCO.STATE_LISTENING  ) != 0) System.out.print(" HORCHEN ");
        if ((new_state & JCO.STATE_TRANSACTION) != 0) System.out.print(" TRANSAKTION ");
        if ((new_state & JCO.STATE_BUSY       ) != 0) System.out.print(" BESCHÄFTIGT ");
      public static void main(String[] argv)
        JCOServer obj = new JCOServer();

    Hello Alexander,
    congratulations to the invention of the wheel....
    Now, what do you think is the function of the application server itself? what you do here is to put a shell around JCO and then try to run it from another shell. Why not just use it from your program?
    I recommend to do some of the examples with JCO and then see what  the difference on this is.

  • Read binary file (DOC, PDF, TIF,...) into SAP with JCO-Server

    I want to read a binary file (DOC, PRD, TIF,...) within a JCO-Server and transfer this file to SAP.
    In SAP we want to store the file in DMS.
    Next step is to read a file from DMS and store the file external using the JCO-Server.
    My questions are:
    1. How can I upload/download any binary in JAVA
    2. How have I to define the communication tabel between SAP and JCO to transfer the data (string,char, raw) and how long must be a row.
    Maybe any code exsamples ?

    We found the way how to define the tables so we can transfer the data between SAP an Java.

Maybe you are looking for