JCO Server Multithreading

Hi,
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.
Thanks

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
                              repository);
           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 ?

Similar Messages

  • JCO.Server Error while trying to execute a RFC program from SAP

    Hi,
    We are connecting to an external registered server program from SAP via Web Methods.
    The external server program is registered with the SAP Gateway. We have created a TCP/IP RFC destination and are able to connect to the destination successfully via SM59.
    An RFC function is created in SAP and is called using the syntax CALL FUNCTION "/NGN/BAPI_STRE_SEARCH_PROCESS" DESTINATION 'PRDB2B'. We have also handled the COMM_FALIURE and SYSTEM_FALIURE exceptions in the function call.
    We are monitoring the gateway via SMGW and see a connection log to the RFC destination as below
    Number - 10
    LUname - dev01
    TPName - sapgw00
    User - KRAORANE
    Status - CONNECTED
    Symbolic - PRDB2B
    Conversation - 86520353
    Prot - REG
    SAP return code - 0
    CPIC rtn code - 0
    The external program returns results as expected.
    However sometimes the RFC fails and returns the message “JCO.Server could not create server function /NGN/BAPI_STRE_SEARCH_PROCESS”.
    We are not able to figure what exactly is causing this error. Any help will be highly appreciated.
    -Kiran

    Hi,
    Please see the below links..
    JCO.Server Error while trying to execute a RFC program from SAP
    Re: JCO.Servcer could not find server function
    Re: JCO.Server could not find server function 'SET_SLD_DATA'
    /people/kathirvel.balakrishnan2/blog/2005/07/26/remote-enable-your-rfchosttoip-to-return-host-ip-to-jco
    Re: interfacing SAP with an existing java applications
    http://help.sap.com/saphelp_nw04/helpdata/en/47/80f671ee6e4b41b63c0fe46bd6e4f8/content.htm
    http://www.sapgenie.com/faq/jco.htm
    Regards
    Chilla..

  • Scenario SAP R/3 --(RFC)-- XI--(RFC)-- JCo.Server

    Hello,
    I am wondering if anyone can send me some feeback for such scenario. SAP R/3 version is 4.6c, SAP XI is 3.0 and JCo are 2.0.12.
    I am having some trouble which I think are link to the fact that the SAP XI is Unicode and not the JCo.Server ... However I was thinking SAP XI will adapt, since it works well for scenario SAP R/3 (RFC)> XI (RFC)> SAP R/3.
    Thanks for your feeback.

    Hi Grégory,
    I guess I faced a similar problem,  the problem was that in the receiver RFC adapter you have to specify both an RFC target system and a system to lookup the metadata.
    The target RFC system hat to have the same unicodeness of the metadata lookup system that means in your case that if jco server is non unicode also you R3 has to be non unicode otherwhise it will not (never) work, because this is a mandatory requirement of the RFC adapter.
    In my case this was not possible so I was redirecting the RFC call to the ABAP stack of XI (where I had exposed the same function module which was simply recalling the same function module to the target system) and it worked/works.
    Regards,
    Sergio

  • JCO - RFC_ERROR_SYSTEM_FAILURE: com/sap/mw/jco/JCO$Server

    Hi,
    I call from Java an ABAP RFC and this RFC in turn call back the Java stack and it fails.
    At Java side I get:
    #1#com.sap.mw.jco.JCO$Exception: (104) RFC_ERROR_SYSTEM_FAILURE: com/sap/mw/jco/JCO$Server
         at com.sap.mw.jco.MiddlewareJRfc.generateJCoException(MiddlewareJRfc.java:516)
         at com.sap.mw.jco.MiddlewareJRfc$Client.execute(MiddlewareJRfc.java:1515)
         at com.sap.mw.jco.JCO$Client.execute(JCO.java:3996)
         at com.sap.mw.jco.JCO$Client.execute(JCO.java:3544)
         at com.sap.sup.admin.setup.SolManRfcAdapter.getJabapLandscape(SolManRfcAdapter.java:787)
         at com.sap.sup.admin.setup.SetupUpgrader.execute(SetupUpgrader.java:52)
    At ABAP side I get:
    Category               ABAP Programming Error
    Runtime Errors      CALL_FUNCTION_REMOTE_ERROR
    ABAP Program      CL_DIAGLS_SMSY_FACTORY========CP
    Application Component  SV-SMG-DIA
    Date and Time        21.09.2009 17:50:59
    Short text
         "com/sap/mw/jco/JCO$Server"
    Is it allowed to call JAVA -> ABAP -> JAVA from JCO point of view?
    Thanks in advance!
    Regards,
    Serge.

    Hi Serge,
    Two doubts:
    - Does your RFC work when you call it directly from the SE37 puting the same input parameters used by Java application?
    - Was the RFC changed after the coding of Java application? If so, the interface between Java and RFC must be regenerated.
    Regards,
    Rodrigo.

  • 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
    Regards
    ABH

    Hi
    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
    Stuart

  • "jco.server.unicode" is gone in JCO 3.0.5??!!

    Recently  we have migrated from   JCO 2.1.8  to  3.0.5.   Currently we are witnessing some problems with communications from non-Unicode Sap systems.
    In the previous version  (JCO 2.1.8)  JCoIDoc.Server had a property "jco.server.unicode"  in the latter one the property  is gone.
    AS far as I  understand, JCo3 Server based on the data sent form a client recognizes encoding and applies proper conversion. However when we try to establish a non-Unicode connection ( from a Unicode enabled system),  through setting In the SM59 transaction (tab MDMP & Unicode) u201ECommunication Type with Target Systemu201D  to Non-Unicode, we are getting  the following error :
    com.sap.conn.idoc.IDocMetaDataUnavailableException: (3) IDOC_ERROR_METADATA_UNAVAILABLE: The meta data for the IDoc type "??????????????????
    ????????å å" with extension "     SAPCFL CF5CL          ???" is unavailable.
            at com.sap.conn.idoc.rt.DefaultIDocDocument.(JCoIDocDocument.java:92)
            at com.sap.conn.idoc.jco.rt.JCoIDocDocument.createIDocDocument(JCoIDocDocument.java:170)
            at com.sap.conn.idoc.jco.rt.JCoIDocRuntime.createIDocDocumentList(JCoIDocRuntime.java:80)
            at com.sap.conn.idoc.jco.JCoIDoc$DefaultJCoIDocRuntime.createIDocDocumentList(JCoIDoc.java:144)
            at com.sap.conn.idoc.jco.rt.DefaultJCoIDocServerWorker$IDocDispatcher.handleRequest(DefaultJCoIDocServerWorker.java:107)
            at com.sap.conn.jco.rt.DefaultServerWorker.dispatchRequest(DefaultServerWorker.java:153)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.dispatchRequest(MiddlewareJavaRfc.java:3300)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.executePlayback(MiddlewareJavaRfc.java:2780)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.playbackTRfc(MiddlewareJavaRfc.java:2598)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.handletRfcRequest(MiddlewareJavaRfc.java:2489)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.listen(MiddlewareJavaRfc.java:2310)
            at com.sap.conn.jco.rt.DefaultServerWorker.dispatch(DefaultServerWorker.java:277)
            at com.sap.conn.jco.rt.DefaultServerWorker.loop(DefaultServerWorker.java:337)
            at com.sap.conn.jco.rt.DefaultServerWorker.run(DefaultServerWorker.java:238)
            at java.lang.Thread.run(Thread.java:619)
    11:15:20,062 ERROR   Sap server details
    Class: com.syncron.bpe.engine.extinterface.sap.idoc.SapIDocServer
    Program id: GIM
    Thread name: JCoServerThread-1
    Registered (at gateway) connection count: 5
    Max thread count: 1
    Exception occured
    com.sap.conn.jco.JCoException: (104) RFC_ERROR_SYSTEM_FAILURE: IDocException occurred (raised by system karbie-nc6400|a_rfc)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc.generateJCoException(MiddlewareJavaRfc.java:639)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.listen(MiddlewareJavaRfc.java:2395)
            at com.sap.conn.jco.rt.DefaultServerWorker.dispatch(DefaultServerWorker.java:277)
            at com.sap.conn.jco.rt.DefaultServerWorker.loop(DefaultServerWorker.java:337)
            at com.sap.conn.jco.rt.DefaultServerWorker.run(DefaultServerWorker.java:238)
            at java.lang.Thread.run(Thread.java:619)
    Caused by: RfcException: karbie-nc6400
        message: IDocException occurred
        Return code: RFC_FAILURE(1)
        error group: 104
        key: RFC_ERROR_SYSTEM_FAILURE
    Exception raised by karbie-nc6400|a_rfc
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.executePlayback(MiddlewareJavaRfc.java:2785)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.playbackTRfc(MiddlewareJavaRfc.java:2598)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.handletRfcRequest(MiddlewareJavaRfc.java:2489)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.listen(MiddlewareJavaRfc.java:2310)
            ... 4 more
    Caused by: RfcException: karbie-nc6400
        message: IDocException occurred
        Return code: RFC_FAILURE(1)
        error group: 104
        key: RFC_ERROR_SYSTEM_FAILURE
    Exception raised by karbie-nc6400|a_rfc
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.dispatchRequest(MiddlewareJavaRfc.java:3329)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.executePlayback(MiddlewareJavaRfc.java:2780)
            ... 7 more
    Caused by: com.sap.conn.idoc.IDocRuntimeException: IDocException occurred
            at com.sap.conn.idoc.jco.rt.DefaultJCoIDocServerWorker$IDocDispatcher.handleRequest(DefaultJCoIDocServerWorker.java:151)
            at com.sap.conn.jco.rt.DefaultServerWorker.dispatchRequest(DefaultServerWorker.java:153)
            at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcServer.dispatchRequest(MiddlewareJavaRfc.java:3300)
            ... 8 more
    Caused by: com.sap.conn.idoc.IDocMetaDataUnavailableException: (3) IDOC_ERROR_METADATA_UNAVAILABLE: The meta data for the IDoc type "???????
    ???????????????????å å" with extension "     SAPCFL CF5CL          ???" is unavailable.
            at com.sap.conn.idoc.rt.DefaultIDocDocument.(JCoIDocDocument.java:92)
            at com.sap.conn.idoc.jco.rt.JCoIDocDocument.createIDocDocument(JCoIDocDocument.java:170)
            at com.sap.conn.idoc.jco.rt.JCoIDocRuntime.createIDocDocumentList(JCoIDocRuntime.java:80)
            at com.sap.conn.idoc.jco.JCoIDoc$DefaultJCoIDocRuntime.createIDocDocumentList(JCoIDoc.java:144)
            at com.sap.conn.idoc.jco.rt.DefaultJCoIDocServerWorker$IDocDispatcher.handleRequest(DefaultJCoIDocServerWorker.java:107)
            ... 10 more
    With JCO 2.1.8  we used to solve it through setting the mentioned "jco.server.unicode"   to 1, in the  current one it seems that there is not much to configure regarding encoding.
    Please advice.

    In unicode ABAP backend systems you always have to set the destination in SM59 to "Unicode" if the communication partner is JCo. There is no choice for setting the Non-Unicode option. It won't work.
    JCo3 does not require a manual setting of the "jco.server.unicode" property any longer. Therefore the property has been deleted. In JCo3 you don't have to take care for this anymore.

  • 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();
              serverThread.start();
              while(!serverThread.isReady) {
                   try {
                        Thread.sleep(5000);
                   } 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);
                   client.connect();
                   IRepository rep = JCO.createRepository("1", client);
                   IFunctionTemplate templ = rep.getFunctionTemplate("TEST_FUNC");
                   JCO.Function function = templ.getFunction();
                   function.getImportParameterList().setValue("STAY", "FIELD1");
                   client.execute(function);
                   JCO.Function function2 = templ.getFunction();
                   function2.getImportParameterList().setValue("STOP", "FIELD1");
                   client.execute(function2);
              } catch(final Exception e) {
                   e.printStackTrace(System.out);
                   serverThread.requestStop();
                   while(serverThread.isAlive) {
                        try {
                             Thread.sleep(5000);
                        } 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");
                   repos.addFunctionInterfaceToCache(getFunctionInterface());
                   server = new TestServer(repos);
                   server.start();
                   System.out.println("Server successfully started");
                   isReady = true;
                   while(!stop) {
                        try {
                             Thread.sleep(1000);
                        } catch(final InterruptedException i) {
                             System.out.println("Wouldn't let me sleep...");
                        stop = server.stopRequested;
                   server.stop();
                   isAlive = false;
                   System.out.println("Server successfully stopped");
              public void requestStop() {
                   server.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: ");
                        System.out.println(importXML);
                        final String input = importParams.getString("FIELD1");
                        System.out.println("FIELD1 value: " + input);
                        JCO.ParameterList exportParams = fct.getExportParameterList();
                        if(input.equals("STOP")) {
                             exportParams.getField("FIELD2").setValue("OK");
                             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) {
                   super(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");
              testRep.addFunctionInterfaceToCache(getFunctionInterface());
              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
    <ol>
    <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>
    </ol>
    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...

  • JCO server problems

    Hello,
    We've developed JCO server which serve as a bridge between SAP R/3 and MS SQL database system. In R/3 system is created TCP/IP destination and JCO server connects to this destination as a registered program.
    In our test environment everything works fine. In customer production environment I face this behaviour:
    After installation of solution it works. But after "some time", when I try to test destination in SM59 and I've got this error:
    SM59 - test connection
    connection to partner broken / CPI-C error CM_PRODUCT_SPECIFIC_ERROR
    COMPONENT      NI (network interface)                                                                         
    COUNTER        2422932                                                                               
    ERROR TEXT     Connection reset by peer                                                                       
    ERROR NUMBER   232                                                                               
    MODULE         niuxi.c                                                                               
    LINE           1204                                                                               
    RETURN CODE    -6 
    What is interesting, problem persist, if i turn off JCO server (I expect error message, that no program is registered!),.... so I change the registered program ID (in SM59), change this in configuration of JCO server - it works.. but again after some time I've got that error.
    R/3 version is 4.6c
    Can you give suggestions, how to solve this problem (where should be the problem)?
    Thanks for any answer.
    Best Regards,
    Juraj

    Hi,
    It gives me the correct IP when I ping yes. It's only when the SLD tries to resolve IP via JCO destinations. Yesterday I put in all hosts in my landscape into the hosts file of the SLD, disabled the NIC that it shouldn't be using and restarted.
    Still it tries to resolve hosts in my landscape to 10.150.83.XXX. How is this possible??
    Thanks - any other ideas?
    .: HP

  • JCO.Server appends null character to string

    I am a complete SAP and JCO newbie so I'll try making as much since as I can, given the fact that I'm not familiar with SAP terminology and technology. I've been lent as a developer to another group which needs a legacy application rewritten. The application processes a RFC and decrypts the RFC encrypted payload and returns it along with a status code.
    I have made progress - I'm able to register my server with the SAP runtime and using the SAP GUI application and the help of a SAP developer, I'm able to make an RFC call to my application. I'm able to read the parameters sent from SAP and write parameters back.
    The problem is that one of the parameters I'm writing back (java.lang.String) appears to have and extra character on SAP side. On the GUI it appears as a '#' (pound) sign. The SAP developer told me the string is terminated with a null character which I know is a C/C++ thing but not a Java thing. I don't think it is a Unicode issue. The Java server is not running in Unicode mode and any attempt to set the jco.server.unicode property (I may have forgotten the exact name) to a value of 1 causes the RFC to fail.
    I think the issue is likely to be the manner in which I defined the function parameters or the manner in which I write them. The following are code snippets:
    Defining the function:
    JCO.MetaData metadata = new JCO.MetaData(Constants.FUNCTION_DECRYPT);
    metadata.addInfo(Constants.PARAMETER_SCHEME,      JCO.TYPE_INT,    255,   0,  0, JCO.IMPORT_PARAMETER, null);
    metadata.addInfo(Constants.PARAMETER_ENCRYPTED,   JCO.TYPE_STRING, 255,   0,  0, JCO.IMPORT_PARAMETER, null);
    metadata.addInfo(Constants.PARAMETER_DECRYPTED,   JCO.TYPE_STRING, 255,   0,  0, JCO.EXPORT_PARAMETER, null);
    metadata.addInfo(Constants.PARAMETER_RETURN_CODE, JCO.TYPE_INT,    255,   0,  0, JCO.EXPORT_PARAMETER, null);
    Server request handling code:
    protected void handleRequest(JCO.Function function)
                    // Obtaining import/export parameter lists.
                    JCO.ParameterList input  = function.getImportParameterList();
                    JCO.ParameterList output = function.getExportParameterList();
                    // Getting scheme and encrypted text parameters.
                    int scheme       = input.getInt(Constants.PARAMETER_SCHEME);
                    String encrypted = input.getString(Constants.PARAMETER_ENCRYPTED);
                    // Decoding base 64 string.
                    byte[] bytes = Base64.decode(encrypted);
                    // Obtaining cipher by scheme and decrypting the text.
                    AppCipher cipher = ApplicationConfiguration.getDecryptor(scheme);
                    if(cipher == null)
                                    logger.error("Unable to get cipher due to an unknown encryption scheme: " + scheme);
                    else
                                    byte[] decrypted = cipher.decrypt(bytes);
                                    String plainText = new String(decrypted);
                                    // Setting decrypted value information and return code.
                                    output.setValue(plainText, Constants.PARAMETER_DECRYPTED);
                                    output.setValue(Constants.RETURN_CODE_SUCCESS, Constants.PARAMETER_RETURN_CODE);

    I seem to have made progress. If I define the parameter type as JCO.TYPE_CHAR instead of JCO.TYPE_STRING, it works:
    metadata.addInfo(Constants.PARAMETER_DECRYPTED,   JCO.TYPE_CHAR,   255,   0,  0, JCO.EXPORT_PARAMETER, null);
    That is the only change I made. I'm still setting the parameter value as java.lang.String. I hope this won't cause issues elsewhere. I was also able to change the field definition and set it as a byte array. However, that had the problem of having to define the exact length of the byte array in the field metadata otherwise the remaining bytes would appear as null bytes on SAP side.

  • JCo Server does not start

    Hi,
    I'm trying to create and start a JCoIDoc.Server on a Web Application Server 700 system. Because I could not find the required classes in the trfc.jar archive on the server I downloaded and packaged the required java connector classes sapidoc.jar and sapidocjco.jar in my EAR file.
    The deployment works fine and the server should be started automatically by a servlet. There are no error entries in the logfile. In addition I can see my own entries in the logfile that the servlet was executed an the server started.
    Nevertheless I can not send anything from an ECC 5.0 system to my java connector server. Using the "netstat -a" command in a DOS console on the Java server I can not even see that the port for incomming idocs is listening.
    Having a look at the ECC 5.0 system using transaction "smgw" I do not see the my JCo Server
    Has anybody an idea what goes wrong or if I forgot anything to realize? The code is quite similar to the jco sample code.
    Or is it in general not possible to start a JCoIDoc.Server on a Web Application Server 700 system?
    Best regards,
    Markus

    you should have no problem doing this....
    However -- as you downloaded the Idoc libraries instead of extracting them for the tar...?
    a) make sure they are accessible (on the classpath) They may need to be in the same directory as the JCO...
    b) make sure they are compatible... read up on the download page and in sapnotes which version exactly you need...
    Or ask your friendly basis admin where he stashed them and use the ones coming with the installation...
    Enjoy

  • 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.
    Stefan

    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 and SAP trfc queue

    Hi,
    we are sending IDocs from our sap system to a JCO server. Let's assume  we are sending 1000 IDocs to it. After sending there are no IDocs in the trfc-queue and the status of all IDocs is "green". Can we assume the JCO server received all 1000 IDocs? Is an  empty trfc-queue always an indicator for a successfull sending process even there are some problems with a weak network(network interruptions). I know IDocs are tansaction based. For my understanding a transaction is okay or not. So an empty trfc queue should indicate everything went fine and all IDocs were received?
    I appreciate any comments on that issue ...
    -Steffen

    If the status of all idocs is green which indicates the communication layer is ok. As you said, the idocs are transaction based. You need to make use of transaction id to confirm everything is fine from the viewpoint of your business logic.
    Dennis

  • 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?
    Regards,
    Dirk-Jan Kloezeman

    Hi,
    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
    Regards
    Bhavesh

  • 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 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.
    Regards
    Here is the code I use to try to connect :
        static String SERVER_NAME1 = "JCO_SERVER";
        static String DESTINATION_NAME1 = "ABAP_AS_WITHOUT_POOL";
        static String DESTINATION_NAME2 = "ABAP_AS_WITH_POOL";
        static
            Properties connectProperties = new Properties();
            connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "172.16.200.114");
            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) {
           step1SimpleServer();
    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("----------------------------------------------------------------");
      System.out.println("call              : " + function.getName());
      System.out
      .println("ConnectionId      : " + serverCtx.getConnectionID());
      System.out.println("SessionId         : " + serverCtx.getSessionID());
      System.out.println("TID               : " + serverCtx.getTID());
      System.out.println("repository name   : "
      + serverCtx.getRepository().getName());
      System.out
      .println("is in transaction : " + serverCtx.isInTransaction());
      System.out.println("is stateful       : "
      + serverCtx.isStatefulSession());
      System.out
      .println("----------------------------------------------------------------");
      System.out.println("gwhost: " + serverCtx.getServer().getGatewayHost());
      System.out.println("gwserv: "
      + serverCtx.getServer().getGatewayService());
      System.out.println("progid: " + serverCtx.getServer().getProgramID());
      System.out
      .println("----------------------------------------------------------------");
      System.out.println("attributes  : ");
      System.out.println(serverCtx.getConnectionAttributes().toString());
      System.out
      .println("----------------------------------------------------------------");
      System.out.println("req text: "
      + function.getImportParameterList().getString("REQUTEXT"));
      function.getExportParameterList().setValue("ECHOTEXT",
      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);
      server.setCallHandlerFactory(factory);
      server.start();
      System.out.println("The program can be stopped using <ctrl>+<c>");
      public static void main(String[] args) {
      step1SimpleServer();
    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";
        static String DESTINATION_NAME1 = "ABAP_AS_WITHOUT_POOL";
        static String DESTINATION_NAME2 = "ABAP_AS_WITH_POOL";
        static
            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);
            if(!cfg.exists())
                try
                    FileOutputStream fos = new FileOutputStream(cfg, false);
                    properties.store(fos, "for tests only !");
                    fos.close();
                catch (Exception e)
                    throw new RuntimeException("Unable to create the destination file " + cfg.getName(), e);
    Regards

Maybe you are looking for