JCo Repository "copy"

Hello,
I'm developing a RFC-Server with JCo.
I would like to read (only once, at the beginning, when the server starts) the repository information of a function module and save them in a static Repository:
    static public class MyRepository extends JCO.BasicRepository
            implements IRepository {
        public MyRepository(String name) {
            super(name);
        public void FillMyRepository() {
            JCO.Client client = null;
            JCO.MetaData fmeta = null;
            fmeta = (MetaData) this.getFunctionInterface("HU_GET_RFC_DATA");
            if ( fmeta == null ) {
                IRepository aRepository = null;
                try {
                    client = JCO.createClient(
                            connClient,     // SAP client
                            connUser,       // userid
                            connPW,         // password
                            connLang,       // language
                            connHost,       // host name
                            connHostSyst ); // System number
                    client.connect();
                    aRepository = JCO.createRepository("aRepository", client);
                    IMetaData fInterface = (IMetaData) aRepository.getFunctionInterface("HU_GET_RFC_DATA").clone();
                    addFunctionInterfaceToCache( (MetaData) fInterface);
                    client.disconnect();       
                } catch (JCO.Exception ex) {
                    System.out.println("Caught an exception: n" + ex);
but then the Server.getFunction doesn't work correctly.
"JCO.Server could not find server function 'HU_GET_RFC_DATA'"
Do you have any idea?
Thanks and regards,
Tommaso

Hi Tommaso,
as far as I know, the moment you create a new Function, it is automatically stored in the Repository.
Every other call to this function ends in this function being retrieved from the JCO Repository. So I think as long as you create only one repository, any Function that you create (Function fx = createFunction("BLAHBLAH");) will be first put into the repository. Which means that only the first call to a Function might take a wee extra than later calls. You don't need to copy a Function into the repository explicitly in my opinion...
Bye,
Sameer

Similar Messages

  • Is sth. like "JCO.Repository.getFunctionTemplate(String BAPI_NAME)" in NCo?

    Hi guys,
    I switched from JCo to NCo and try to find the same functions that are available under JCO.
    My specific problem is this:
    I integrated SAP in our applications using XML with JCo until now, e.g.
    JCO.Function.getImportParameterList.fromXML(String myImportParameters)
    This code snippet e.g. fills the parameters for my BAPI.
    To have the correct XML input string, I organized me the structure of the parameter XML representation via
    JCO.Function.getImportParamterList.toXML()
    I got the function using
    IFunctionTemplate ft = myRepository.getFunctionTemplate(bapiName.toUpperCase());
    JCO.Function function = ft.getFunction();
    XML has the very advantage, that you can pass any values inside the fields an thus use it in processes.
    Now I'm looking for the same feature in NCo:
    I want to specify the BAPI name in my little app and receive an XML representation of the needed Import/Export/Table parameters. But I couldn't find any method in the whole NCo class library to do this.
    Can someone help me?

    Well, I'll try my best. If nothing else works, I'll call my old JCo via some SOAP with the BAPINAME as parameter and let JCo return the XML representation
    Thanks for the help!

  • XI/PI: Integration Repository- copy object options meaning?

    Hi All,
    When we copy objects within IR we get follwing two options,
    1. With all dependents objects
    2. Save original as reference
    can anyone tell me implications of chosing these options?
    why and when should we chose them?
    Thanks and Regards,
    Ujwal

    >>1. With all dependents objects
    When u copy Mesage Type, it's dependent object Data type is also copied.. similarly Interface Mapping will copy Message Mapping also.. this is applicable for all IR obects that are dependent...
    >>2. Save original as reference
    The copied obects that are there in the new Namespace will refer to it's dependen't objects that is there in the original/initial namespace...
    >>can anyone tell me implications of chosing these options?
    >>why and when should we chose them?
    depend's... if the initial/original namespace are not going to be moved to other box and only the new namespace is to be moved then even the dependent objects should be copied to the new namespace....
    ~SaNv...

  • How to flush the cache of a JCO repository ?

    Does anybody now how to flush the cache of the JCO repositories of pools managed by Netweaver application server without restarting the JVM ?
    The reason I'm asking is that, whenever a tables or structure changes on ABAP side (CRM,  IS-U, R/3), even though we redeploy the J2EE applications, they do not see the new definitions, and we have to restart the JVMs.
    This is particularily annoying in an "high availability" production environment such a ours.
    We need a close to 24/7 up time, and putting down the JVM for even a few minutes is becoming a problem.
    I'd like to be able to manually flush the repositories when needed.
    For example, is it possible to write a small java application that could perform the flush on a single request ?
    I did not try writing any code to do so yet, but I guess this snippet can do the work:
    IRepository rCRM = JCO.createRepository("FLUSH_CRM", "java:comp/env/eis/pool_crm")
    while (rCRM !=null)
       String [] crmFuncts  = rCRM.getCachedFunctionInterfaces()
       String [] crmStructs = rCRM.getCachedStructureDefinitions()
       for (int i=0; crmFuncts!=null && i<crmFuncts.lenght; i++)
          rCRM.removeFunctionInterfaceFromCache(crmFuncts<i>);
       for (int i=0; crmStructs!=null && i<crmStructs.lenght; i++)
          rCRM.removeStructureDefinitionFromCache(crmStructs<i>);
       rCRM = rCRM.getNextRepository();
    Does it ?
    Edited by: Croussette Yves on Jun 9, 2008 8:46 PM
    Edited by: Croussette Yves on Jun 9, 2008 8:47 PM

    Hi,
    Please check these link:-
    1.[https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/3219]
    2.https://www.sdn.sap.com/irj/scn/thread?messageID=601915
    3.https://www.sdn.sap.com/irj/scn/thread?messageID=135202
    Best Regards,
    Atul Bhatia

  • JCO.Client not connected in repository call (EP7)

    Hi guys,
    please can someone help me with this error msg?
    I don’t understand why we getting this error msg, for some users they can run reports and others get this msg.
    500 Internal Server Error
    BEx Web Application
    Failed to process request. Please contact your system administrator.
    [Hide]
    Error Summary
    While processing the current request, an exception occured which could not be handled by the application or the framework.
    If the information contained on this page doesn't help you to find and correct the cause of the problem, please contact your system administrator.
    To facilitate analysis of the problem, keep a copy of this error page. Hint: Most browsers allow to select all content, copy it and then paste it into an empty document (e.g. email or simple text file).
    Root Cause
    The initial exception that caused the request to fail, was: 
    JCO.Client not connected in repository call
    com.sap.mw.jco.JCO$Exception: (102) JCO_ERROR_COMMUNICATION: JCO.Client not connected in repository call
    at com.sap.mw.jco.JCO$Repository.getVersion(JCO.java:20290)
    at com.sap.mw.jco.JCO$Repository.queryFunctionInterface(JCO.java:20630)
    at com.sap.mw.jco.JCO$Repository.queryFunctionInterface(JCO.java:20351)
    at com.sap.mw.jco.JCO$Repository.getFunctionInterface(JCO.java:20465)
    at com.sap.mw.jco.JCO$BasicRepository.getFunctionTemplate(JCO.java:19533)
    Details: Full Exception Chain
    System Environment
    Server
    BI Java     Release: 7 - Patch level: 0000000009 - Description: BI Web Applications Java - Additional info:  - Production mode: true
    BI ABAP     unknown
    Java Virtual Machine     Java HotSpot(TM) 64-Bit Server VM - Sun Microsystems Inc. - 1.4.2_12-b03
    Operating System     Linux - ia64 - 2.6.9-22.0.1.EL
    Full Exception Chain
    Log ID     0012799E22D40054000001AF00006B9400042A20B9AF8861
    com.sap.ip.bi.base.exception.BIBaseRuntimeException: JCo exception thrown when connecting to system "SAP_BW"
         at com.sap.ip.bi.base.application.service.rfcproxy.impl.jco640.Jco640Proxy.createFunction(Jco640Proxy.java:87)
         at com.sap.ip.bi.base.application.service.impl.application.ApplicationSettingsService.initializeProperties(ApplicationSettingsService.java:130)
         at com.sap.ip.bi.base.application.service.impl.application.ApplicationSettingsService.initialization(ApplicationSettingsService.java:124)
         at com.sap.ip.bi.base.application.impl.Application.createService(Application.java:477)
         at com.sap.ip.bi.base.application.impl.Application.getProperty(Application.java:624)
         at com.sap.ip.bi.base.application.impl.Application.initialization(Application.java:229)
         at com.sap.ip.bi.base.application.ApplicationFactory.createApplication(ApplicationFactory.java:132)
         at com.sap.ip.bi.base.application.ApplicationFactory.createApplication(ApplicationFactory.java:63)
         at com.sap.ip.bi.webapplications.runtime.impl.Page.constructPage(Page.java:729)
         at com.sap.ip.bi.webapplications.runtime.impl.Page.<init>(Page.java:647)
         at com.sap.ip.bi.webapplications.runtime.controller.impl.Controller.createPage(Controller.java:504)
         at com.sap.ip.bi.webapplications.runtime.controller.impl.Controller.doProcessRequest(Controller.java:911)
         at com.sap.ip.bi.webapplications.runtime.controller.impl.Controller.processRequest(Controller.java:851)
         at com.sap.ip.bi.webapplications.runtime.jsp.portal.services.BIRuntimeService.handleRequest(BIRuntimeService.java:380)
         at com.sap.ip.bi.webapplications.runtime.jsp.portal.components.LauncherComponent.doContent(LauncherComponent.java:21)
         at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
         at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
         at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
         at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
         at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:646)
         at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
         at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
         at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)
         at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:522)
    Many thanks in advance
    Jo-lize

    Hi, you can fix the problem ?
    i have same problem in BI7 and EP7, when launch Template Installer.
    <b>Create Destination in ABAP Import not successful Element 'SAPConfigLib.DES.Unclassified.createRfcDestination':!BrokerImport.import_of_element_failed!!BrokerImport.Fehler!com.sap.tc.lm.ctc.cul.cpi.exceptions.CPIBaseException: <Localization failed: ResourceBundle='com.sap.tc.lm.ctc.cul.cpi.CPIResourceBundle', ID='com.sap.tc.lm.ctc.cul.cpi.BaseException_BASE_EXCEPTION', Arguments: []> : Can't find resource for bundle java.util.PropertyResourceBundle, key com.sap.tc.lm.ctc.cul.cpi.BaseException_BASE_EXCEPTION:com.sap.tc.lm.ctc.provider.javaServiceProvider.JavaServiceWriter.writeElement!BrokerImport.LINE!157-:com.sap.tc.lm.ctc.cul.broker.BrokerImport.importElement.86
    -:com.sap.tc.lm.ctc.cul.broker.BrokerImport.importElement.128
    -:com.sap.tc.lm.ctc.cul.broker.BrokerImport.importElement.128
    -:com.sap.tc.lm.ctc.cul.serviceimpl.importservice.CULConfigurationImport.importConfiguration.96
    -:com.sap.tc.lm.ctc.ccl.templateinstaller.StepExecuter.run.41
    Element 'SAPConfigLib.DES.Unclassified.createRfcDestination':Error during executing Java Reflection:JCO.Client not connected in repository call
    </b>

  • Need help on JCo

    Hi,
    I am getting error message while running JCo java code. I followed the given steps in the installation guide. I know i did something wrong in this.
    I created a folder C:\JCO and unzipped the downloaded JCo files librfc32.dll, sapjcorfc.dll and sapjco.jar.
    Copied the file librfc32.dll from C:\JCO directory to C:\WINNT\SYSTEM32
    Added the path c:\JCO\sapjco.jar; in the environmental variables. [I followed the following --> Right Click on My Computer --> Properties --> Advanced --> Environment Variables --> Edited the existing path and added with java path like C:\j2sdk1.4.2_05\bin;c:\JCO\sapjco.jar;].
    After this I am trying to execute the following code. It is copiling without any problem and giving error message while run mode.
    C:\JCO>java Bapi1
    Exception in thread "main" java.lang.NoClassDefFoundError: com/sap/mw/jco/JCO$Structure
    ******java code*****
    import com.sap.mw.jco.*;
    public class Bapi1 extends Object {
       JCO.Client mConnection;
       JCO.Repository mRepository;
       public Bapi1() {
          try {
             // Change the logon information to your own system/user
             mConnection =
                JCO.createClient("020", // SAP client
                  "myuserid", // userid
                  "****", // password
                  "EN", // language
                  "myerp server host name", // application server host name
                  "00"); // system number
            mConnection.connect();
            mRepository = new JCO.Repository("SAPJCo", mConnection);
          catch (Exception ex) {
            ex.printStackTrace();
            System.exit(1);
          JCO.Function function = null;
          JCO.Table codes = null;
          try {
             function = this.createFunction("BAPI_COMPANYCODE_GETLIST");
             if (function == null) {
               System.out.println("BAPI_COMPANYCODE_GETLIST" +
                                  " not found in SAP.");
               System.exit(1);
             mConnection.execute(function);
             JCO.Structure returnStructure =
               function.getExportParameterList().getStructure("RETURN");
             if (! (returnStructure.getString("TYPE").equals("") ||
                    returnStructure.getString("TYPE").equals("S")) ) {
               System.out.println(returnStructure.getString("MESSAGE"));
               System.exit(1);
             codes =
               function.getTableParameterList().getTable("COMPANYCODE_LIST");
             for (int i = 0; i < codes.getNumRows(); i++) {
               codes.setRow(i);
               System.out.println(codes.getString("COMP_CODE") + '\t' +
                                  codes.getString("COMP_NAME"));
          catch (Exception ex) {
            ex.printStackTrace();
            System.exit(1);
          try {
            codes.firstRow();
            for (int i = 0; i < codes.getNumRows(); i++, codes.nextRow()) {
              function = this.createFunction("BAPI_COMPANYCODE_GETDETAIL");
              if (function == null) {
                System.out.println("BAPI_COMPANYCODE_GETDETAIL" +
                                   " not found in SAP.");
                System.exit(1);
         function.getImportParameterList().
           setValue(codes.getString("COMP_CODE"), "COMPANYCODEID");
         function.getExportParameterList().
           setActive(false, "COMPANYCODE_ADDRESS");
         mConnection.execute(function);
         JCO.Structure returnStructure =
           function.getExportParameterList().getStructure("RETURN");
         if (! (returnStructure.getString("TYPE").equals("") ||
                returnStructure.getString("TYPE").equals("S") ||
                returnStructure.getString("TYPE").equals("W")) ) {
            System.out.println(returnStructure.getString("MESSAGE"));
         JCO.Structure detail =
           function.getExportParameterList().
           getStructure("COMPANYCODE_DETAIL");
         System.out.println(detail.getString("COMP_CODE") + '\t' +
                            detail.getString("COUNTRY") + '\t' +
                            detail.getString("CITY"));
      catch (Exception ex) {
        ex.printStackTrace();
        System.exit(1);
      mConnection.disconnect();
    public JCO.Function createFunction(String name) throws Exception {
       try {
         IFunctionTemplate ft =
            mRepository.getFunctionTemplate(name.toUpperCase());
         if (ft == null)
           return null;
         return ft.getFunction();
       catch (Exception ex) {
         throw new Exception("Problem retrieving JCO.Function object.");
    public static void main (String args[]) {
       Bapi1 app = new Bapi1();

    Hi Venu,
    You have to add the java library sapjco.jar to the java classpath instead of the system classpath. You can do this by adding the -cp or -classpath parameter to your java call. So then you would get:
    java -classpath C:JCOsapjco.jar Bapi1
    Hope this helps,
    Johan

  • Look Up API through JCO

    Hi all,
    I m using look up through JCO and calling a RFC on backend R/3 for the particular validation.I m using UDF for that.In the UDF i have specified imports as:-
    imports :-java.util.;java.lang.obj.;com.sap.aii.mapping.lookup.;com.sap.mw.jco.;java.io.*;
    source code --
    //write your code here
    JCO.Repository  myRepository;
    // Change the logon information to your own system/user
    JCO.Client  myConnection =  JCO.createClient(
        // all the client information namely client ,user id pwd etc
    myConnection.connect();
    // create repository
    myRepository = new JCO.Repository( "SAPLookup", myConnection );
    // Create function
    JCO.Function function = null;
    IFunctionTemplate ft = mRepository.getFunctionTemplate("xxxxx"); //Name of RFC
    function = ft.getFunction();
    // Obtain parameter list for function
    JCO.ParameterList input = function.getImportParameterList();
    // Pass function parameters
    input.setValue( a , "xxxxx" ); //import parameter of RFC, a is input argument.
    myConnection.execute( function );
    String ret = function.getExportParameterList().getString( "XXXX" ); //export param
    myConnection.disconnect();
    return ret;
    however on test  i m getting follwing error:
    Source code has syntax error:  D:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map6df266d0f96411dbb2a4000bcd3f5f3d/source/com/sap/xi/tf/_MM_Source_To_Target_.java:157: 'class' or 'interface' expected public static void main(String[] args) throws Exception{/!_$ClNRep_/_MM_Source_To_Target_ st = new /!_$ClNRep_/_MM_Source_To_Target_(); st.testExecute(); }
    Can anybody help me out in rectifying this Syntax errror.
    Regards,
    AshwinM

    You are hardcoding the user id , password etc in your UDF. This is something will cause issues asyou move your objects across environments from Dev to Qaulity and production.
    You cannot change the user id and passwordi n your mapping code in your Quality and Prodction. Use of RFC Lookup is strongly recommended with the RFC adapter.
    I dont think using RFC Lookup API causes any perfromance degradations. We have used this feature multiple times in and have never faced performance constraints as a result of this.
    Regards
    Bhavesh

  • Help needed in jco programming

    hi friends
    when i try to connect with SAP server using jco i have some probem.
    Connection with jco program is working fine. I make it ajava file and run separately).
    Now i want do that with jsp.
    I am getting error of
    Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
    org.apache.jsp.barcodeMainP_jsp._jspService(org.apache.jsp.barcodeMainP_jsp:124)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.NoClassDefFoundError
    mySAP.JcoTest.createConnection(JcoTest.java:78)
    mySAP.JcoTest.<init>(JcoTest.java:8)
    org.apache.jsp.barcodeMainP_jsp._jspService(org.apache.jsp.barcodeMainP_jsp:74)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
    My Program is
    My java program
    package mySAP;
    import com.sap.mw.jco.*;
    public class JcoTest {
         public JcoTest() {
              createConnection();
              retrieveRepository();
              closeConnection();
         public StringBuffer fetchData(String Dofrom, String Doto) {
              StringBuffer stringbuffer = new StringBuffer();
              try {
                   com.sap.mw.jco.JCO.Function function = getFunction("Z_BC_LABEL");
                   System.out.println("SUCC YOU GOT CONN");
                   com.sap.mw.jco.JCO.ParameterList listParams = function
                             .getImportParameterList();
                   System.out.println(listParams);
                   listParams.setValue(Dofrom, "DO_FROM");
                   listParams.setValue(Doto, "DO_TO");
                   theConnection.execute(function);
                   System.out.println("SUCC function executed success");
                   com.sap.mw.jco.JCO.Table tableList = function
                             .getTableParameterList().getTable("ZBAR");
                   String s3 = "\t";
                   stringbuffer.append("vbeln" + s3);
                   stringbuffer.append("uecha" + s3);
                   stringbuffer.append("kdmat" + s3);
                   stringbuffer.append("lifmg" + s3);
                   stringbuffer.append("bstkd" + s3);
                   stringbuffer.append("groes" + s3);
                   stringbuffer.append("name1" + s3);
                   stringbuffer.append("lfdat" + s3);
                   stringbuffer.append("posnr" + s3);
                   stringbuffer.append("lifmg  bstkd " + "\n");
                   // stringbuffer.append("\t");
                   if (tableList.getNumRows() > 0)
                        do {
                             com.sap.mw.jco.JCO.Field tabField;
                             for (com.sap.mw.jco.JCO.FieldIterator fI = tableList
                                       .fields(); fI.hasMoreElements();
                             stringbuffer.append(tabField.getString() + s3)) {
                                  tabField = fI.nextField();
                             stringbuffer.append("\n");
                        } while (tableList.nextRow());
                   else
                        System.out.println("sorry no records...better luck next time");
              } catch (Exception ex) {
                   ex.printStackTrace();
              return stringbuffer;
         private static void createConnection() {
              try {
                   theConnection = JCO.createClient("080", "xxxx", "xxxx", "EN",
                             "xxx.xxx.xx.xx", "00");
                   theConnection.connect();
              } catch (Exception ex) {
                   System.out.println("Failed to connect to SAP system");
         private static void closeConnection() {
              try {
                   theConnection.disconnect();
              } catch (Exception ex) {
                   System.out.println("Failed to connect to SAP system");
         private static void retrieveRepository() {
              try {
                   theRepository = new com.sap.mw.jco.JCO.Repository("saprep",
                             theConnection);
              } catch (Exception ex) {
                   System.out.println("failed to retrieve repository");
         public static com.sap.mw.jco.JCO.Function getFunction(String name) {
              return theRepository.getFunctionTemplate(name.toUpperCase())
                        .getFunction();
         private static com.sap.mw.jco.JCO.Client theConnection;
         private static IRepository theRepository;
    My JSP calling Program
    <%@page language="java"
         import="java.sql.*,java.io.*,mySAP.*,java.net.URL;"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <%!StringBuffer stringbuffer = new StringBuffer();
         int testemp;%>
    <%
         String dofrom;
         String doto;
         String s;
         String s1;
         dofrom = request.getParameter("DOFrom");
         doto = request.getParameter("DOTo");
         ResultSet resultset;
         String flag = request.getParameter("dall");
         mySAP.JcoTest obj = new mySAP.JcoTest();
         StringBuffer sb = obj.fetchData("one", "two");
         out.println(sb);
         try {
              StringBuffer stringbuffer = new StringBuffer();
              String separator = System.getProperty("file.separator");
              String path = System.getProperty("user.dir") + separator;
         } catch (Exception e) {
              out.println("error%%%%%%%%%" + e);
    %>
    </body>
    </html>

    NoClassDefFoundError always means Class Path problem. The classpath of the Servlet is not the same as a normal Java Application. Move any of the necessary dependencies to the Servlet Context's class path (jars in the WEB-INF/lib/ or classes in WEB-INF/classes/).

  • How to connect to R/3 via JCo using MYSAPSSO2?

    Hello!
    I'm developing a J2EE application who resides in an EP with Single Sign On. I have to retrieve some data from R/3, the way I want to connect is via JCo using MYSAPSSO.
    I have read that is possible to connect passing MYSAPSSO2 as <i>user</i> and its value as <i>password</i>. The java code in the jsp is something like this:
    javax.servlet.http.Cookie [] my_cookies = request.getCookies();
    java.util.Hashtable cks = new Hashtable();
    for(int i=0;i<my_cookies.length;i++){
         cks.put(my_cookies<i>.getName(),java.net.URLDecoder.decode(my_cookies<i>.getValue()));
    String user = "$MYSAPSSO2$";
    String pass = (String)cks.get("MYSAPSSO2");
    JCO.Client conex;
    JCO.Repository rep;
    boolean ok=true;
    conex = JCO.createClient("000",user,pass,"es","192.168.0.1","00","","");
    try{
         conex.connect();
         rep = new JCO.Repository("mirep",conex);
    } catch (Exception e){
         out.write("<br>"e"<br>");
         ok = false;
    if (ok)
         conex.disconnect();
    We are working with EP6 SP2, WAS 6.20.
    The error is:
    com.sap.mw.jco.JCO$Exception: (103) RFC_ERROR_LOGON_FAILURE: Se ha recibido un ticket SSP que no se puede interpretar
    (I translate you:)
    RFC_ERROR_LOGON_FAILURE: unable to interpret a retrieved SSP ticket
    Thank you all!!

    Ok!
    I have solve the problem. So, I was trying to connect via SSO within an user that was not registered in R/3 and I forgot it.
    Sorry for the inconvenience.

  • Use of JCo

    Hello Everyone,
                           I m developing one portal application using NWDS. This application connects to backend SAP R/3 system & fetches the data in some table. i have decided to use JCo to connect to R/3 system. But in my code it gives me error at the import statement "import com.sap.mw.jco.JCO;". so my question is , Are there any configurations or any .JAR files need to be added for using JCo while developing portal application through NWDS?
    Thanks,
    Chetan

    hi
    try like that
    import com.sap.mw.jco.IFunctionTemplate;
    import com.sap.mw.jco.JCO;
    import com.sapportals.htmlb.InputField;
    import com.sapportals.htmlb.event.Event;
    import com.sapportals.htmlb.event.TableNavigationEvent;
    import com.sapportals.htmlb.page.DynPage;
    import com.sapportals.htmlb.page.PageException;
    import com.sapportals.portal.htmlb.page.JSPDynPage;
    import com.sapportals.portal.htmlb.page.PageProcessorComponent;
    import com.sapportals.portal.prt.component.IPortalComponentContext;
    import com.sapportals.portal.prt.component.IPortalComponentProfile;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    public class TableApp extends PageProcessorComponent {
          public DynPage getPage(){
                  return new TableAppDynPage();
        public static JCO.Client mConnection;
        public static class TableAppDynPage extends JSPDynPage{
              private TableBean myTableBean = null;
              private int visibleRow = 1;
              int flag=0;
              String inf1,inf2;
              public static JCO.Client mConnection = null;
              public static JCO.Repository mRepository = null;
              public static JCO.Function function = null;
              private String name1,name2;
             public void doInitialization(){
                    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                    IPortalComponentContext myContext = request.getComponentContext();
                    myTableBean = new TableBean();
                    myContext.putValue("myTableBean", myTableBean);
                    mConnection = JCO.createClient("200",
                                                         "jbabu",
                                                         "sy5tech!",
                                                         "EN",
                                                         "10.5.5.33",
                                                         "00");
                   mConnection.connect();
                   mRepository = new JCO.Repository("myRep",mConnection);
                   IFunctionTemplate ft = mRepository.getFunctionTemplate("BAPI_BANK_GETLIST");
                   function = ft.getFunction();
                   setJspName("Input.jsp");
        public void doProcessAfterInput() throws PageException {
                    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                    IPortalComponentContext context = request.getComponentContext();
                         myTableBean = (TableBean) context.getValue("myTableBean");
                   try{
                       InputField myInputField1 = (InputField) getComponentByName("inf1");
                        if (myInputField1 != null) {
                             this.name1 = myInputField1.getValueAsDataType().toString();
                        InputField myInputField2 = (InputField) getComponentByName("inf2");
                        if (myInputField2 != null) {
                             this.name2 = myInputField2.getValueAsDataType().toString();
                   JCO.ParameterList imParam1 = function.getImportParameterList();
                   imParam1.setValue(name1,"BANK_CTRY");
                   JCO.ParameterList imParam2 = function.getImportParameterList();
                   imParam2.setValue(name2,"MAX_ROWS");
                   mConnection.execute(function);
                   JCO.ParameterList exParam = function.getTableParameterList();
                   JCO.Table table = exParam.getTable("BANK_LIST");
                   myTableBean.setName(table);
                    mConnection.disconnect();
              catch(Exception ex)
                   ex.printStackTrace();
         public void doProcessBeforeOutput() throws PageException {
                   if(flag == 1)
                      this.setJspName("OutputTable.jsp");
         public void onButtonClicked(Event event) throws PageException
                    flag = 1;       
              public void onNavigation(Event event) throws PageException
                                  TableNavigationEvent tne = (TableNavigationEvent) event;
                                       this.visibleRow = tne.getFirstVisibleRowAfter();
                                       myTableBean.setVisibleRow(new Integer(this.visibleRow).toString());

  • Third party system (JCO) ---RFC--- PI ---RFC--- ECC

    Hello all,
    We are trying to implement the following scenario:
    Third party system (JCO) -RFC-> PI -RFC-> SAP ECC
    The third party system connect to PI via Java Connector API with a know user id in PI. After that third party system tries to obtain the RFC that is already implemented and remote enabled in SAP ECC environment. But at this step there is something wrong in third party system software because we are not able to obtain the RFC interface and metadata from PI repository.
    1. This step is working correctly. Connection is OK.
                JCO.Client mConnectionPI = JCO.createClient("100", // SAP client
                                                                                    "user_id", // userid
                                                                                    "********", // password
                                                                                    "pt", // language
                                                                                    "10.x.x.x", // application server host name
                                                                                    "01"); // system number
                mConnectionPI.connect();
    2. This step is not working correctly:
                JCO.Repository repository = new JCO.Repository("TestRep", mConnectionPI);
                IFunctionTemplate ftemplate = repository.getFunctionTemplate("Z_RFC_XXX"); - not found exception
    We would like to know if there is something missing in any environment that we have to configure or implement in order to fix this issue. Thanks a lot.

    Hi Primini,
    couple of stupid-but-necessary questions:
    1) have you imported the RFC model in PI Repository?
    You don't need to have the RFC metadata in PI ABAP stack (there is no point in doing that), but rather in the PI Repository/ESR, within the SWCV you've created.
    Check the "Activities" session of this link for more details:
    http://help.sap.com/saphelp_nw70ehp2/helpdata/en/2b/a48f3c685bc358e10000000a11405a/frameset.htm
    2) if you have done 1), have you configured the RFC Sender scenario properly?
    I mean, have you ran the configuration wizard to create the agreements & determinations, setting the RFC interface as both the sender and the receiver interface? Of course, the systems would be different: as the sender system, you'll have a Business Service representing the legacy/JCo system; as the receiver, you'll have the ERP Business System.
    This should make your scenario work.
    If it doesn't, try one more thing: in the JCo code, just for the metadata repository connection, use a connection to the ERP system. But for the actual call, use the PI system.
    Let us know the results.
    Best regards,
    Henrique.

  • A  problem about JCO

    Hi experts:
          I  meet a strange  problem,  i  deploy a webdynpro java   program which  use  rfc  module.  The SLD and JCO  connection was  good. When running this program , sometimes  it can used  but  sometime  it  run with error.
         The  error message like these:
         com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: CPIC-CALL: CMRCV on convId: 89492625
    LOCATION    CPIC (TCP/IP) on local host with Unicode
    ERROR       connection to partner '10.10.10.20:3300' broken
    TIME        Tue May 11 16:04:19 201
    RELEASE     701
    COMPONENT   NI (network interface)
    VERSION     38
    RC          -6
    MODULE      nixxi.cpp
    LINE        3960
    DETAIL      NiIWrite
    SYSTEM CALL writev
    ERRNO       32
    ERRNO TEXT  There is no process to read data written to a pipe.
    COUNTER     3
            at com.sap.mw.jco.MiddlewareJRfc.generateJCoException(MiddlewareJRfc.java:516)
            at com.sap.mw.jco.MiddlewareJRfc$Client.execute(MiddlewareJRfc.java:1514)
            at com.sap.mw.jco.JCO$Client.execute(JCO.java:3980)
            at com.sap.mw.jco.JCO$Client.execute(JCO.java:3417)
            at com.sap.mw.jco.JCO$Repository.execute(JCO.java:20577)
            at com.sap.mw.jco.JCO$Repository.queryFunctionInterface(JCO.java:20916)
            at com.sap.mw.jco.JCO$Repository.queryFunctionInterface(JCO.java:20602)
            at com.sap.mw.jco.JCO$Repository.getFunctionInterface(JCO.java:20706)
      How can do with it?
      Thank a lot!

    Hi,
    Please take a look at the below link.
    Hope this will help you.
    http://wiki.sdn.sap.com/wiki/display/EP/TroubleshootingSAPJavaConnector%28JCo%29
    Also check the system connection test.
    Regards,
    Sandip
    Edited by: Kundu Sandip on May 12, 2010 9:28 AM

  • Access ABAP Table using Java (NWDS/JCO)

    All,
    I am trying to setup a jco connection from java program through NWDS to ECC abap table.
    However I am getting the following error in NWDS:
    Exception in thread "main" 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 [C:\Program Files\Java\jdk1.6.0_45\bin\sapjcorfc.dll: Access is denied]. java.library.path [C:\Program Files\Java\jdk1.6.0_45\bin;.]
    and a parity error on my system:
    "Parity blocked an attempt by javaw.exe to run sapjcorfc.dll because the file is not approved.  If you require access to this file, please contact your system administrator.  Scroll down for diagnostic data."
    Here is the Java code...per the SAP website:
    package com.sap.pi.updateAbapSxmbAdminParams;
    import com.sap.mw.jco.*;
    public class ReadPiAbapTables {
      private static JCO.Client theConnection;
      private static IRepository theRepository;
      public static void main(String[] args) {
       createConnection();
       retrieveRepository(); 
       try {
        JCO.Function function = getFunction("RFC_READ_TABLE");
        JCO.ParameterList listParams = function.getImportParameterList();
        listParams.setValue("BSAUTHORS", "QUERY_TABLE");
        theConnection.execute(function);
        JCO.Table tableList = function.getTableParameterList().getTable("SXMSCONFVLV");
        if (tableList.getNumRows() > 0) {
         do {
          for (JCO.FieldIterator fI = tableList.fields();
          fI.hasMoreElements();)
           JCO.Field tabField = fI.nextField();
           System.out.println(tabField.getName()
             + ":t" +
             tabField.getString());
          System.out.println("n");
         while (tableList.nextRow() == true);
       catch (Exception ex) {
        ex.printStackTrace();
      private static void createConnection() {
       try {
        theConnection = JCO.createClient("aaa", "aaa", "aaa", "aa", "aa", "aa");
        theConnection.connect();
       catch (Exception ex) {
        System.out.println("Failed to connect to SAP system");
      private static void retrieveRepository() {
       try {
        theRepository = new JCO.Repository("saprep", theConnection);
       catch (Exception ex)
        System.out.println("failed to retrieve repository");
      public static JCO.Function getFunction(String name) {
       try {
        return theRepository.getFunctionTemplate(name.toUpperCase()).getFunction();
       catch (Exception ex) {
        ex.printStackTrace();
       return null;

    Hi Vicky,
    You need authorization to the S_TABU_DIS object, talk with the ABAP basis team about this to find the more restrictive role.
    It's not a good idea to use the RFC_READ_TABLE, for the wide permissions needed. You could think to develop a Z RFC for this.  You can check pros/cons in this document: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a83ec690-0201-0010-14ac-bd1d75e24a7d?overridelayout=t…
    Regards.

  • JCO from Message Mapping in XI

    I'm trying to create a function in XI Message Mapping that saves some information in a XI DB table using JCO.
    I've created DB table ZEDI with Fields A,B,C,D. My function is following:
    imports:java.lang.String;java.io.ByteArrayInputStream;java.io.InputStream;com.sap.mw.jco.*;
    public String WriteTable(String ISA,String GS,Container container){
    //write your code here
    String DBTABLE = "ZEDI";
    String sapClient = "200";
    String hostName = "10.1.10.81";
    String systemNumber = "00";
    String userName = "DBuser";
    String password = "DBpass";
    String language = "EN";
    int i     = 0;
    JCO.Repository mRepository;
    JCO.Client mConnection = JCO.createClient(
                   sapClient,
                   userName,
                   password,
                   language,
                   hostName,
                   systemNumber );
    // connect to SAP
    mConnection.connect();
    // create repository
    mRepository = new JCO.Repository( "GenericLookup", mConnection );
    // create function template to select data from any table
    JCO.Function function = null;
    IFunctionTemplate ft = mRepository.getFunctionTemplate("ZEDI");
    function = ft.getFunction();
    //JCO.ParameterList lookupFieldPos  = function.getImportParameterList();
    JCO.Table FieldPos = function.getTableParameterList().getTable("ZEDI");
    // Pass function parameters
    FieldPos.setValue(ISA,"A");
    FieldPos.setValue(GS,"B");
    mConnection.execute(function );
    mConnection.disconnect();
    return ISA;
    Message Mapping test returns Exception:[java.lang.NullPointerException].
    Do you have any idea what do I need to change to make it working?
    Thanks!
    Naycho

    Hi Naycho
    You have created a SAP table, but you have to create ABAP Function Module (RFC) with import /export parameters to access tables via JCO.
    The null pointer exception is because - IFunctionTemplate ft = mRepository.getFunctionTemplate("ZEDI");
    is searching for a function not table name.
    hope this helps
    Regards
    Prahllad

  • Jco memory leak

    Hello all,
    I am currently using JCO 2.1.6 oN HP UX 11i to connect to a SAP WAS 6.40.
    I see that my application is leaking in memory. After quite some troubleshooting, I managed to build a testbed showing that it seems that it is leaking in the memory DATA region. This is usually happenning when there is a leak in a JNI layer.
    Did anyone experience a similar issue? Is there a more recent SL librray than the one provided with 2.1.6.
    Also when the program is starting I am seeing the following issue.
       /usr/lib/dld.sl: Can't find path for shared library: dsrlib.sl
       /usr/lib/dld.sl: No such file or directory
    The mapping from JCO object to java object is done using a program based on the principle of "sap2java".
    An extract of my testbed is
        public DataWrapper execute(String packageName, String functionName, Object inputParams)
                throws JCO.Exception, IllegalArgumentException, MappingException {
             IFunctionTemplate functionTemplate = null;
             JCO.Function function = null;
             JCO.ParameterList input = null;
            String fName = functionName.trim().toUpperCase();
            JCO.Client connection = null;
            try {
                connection = JCO.getClient("mypool", true);
                functionTemplate = getFunctionTemplate(fName, connection);
                 JCO.Repository repository = new JCO.Repository("SID","mypool");
                 functionTemplate = repository.getFunctionTemplate(functionName);
                 // don't cache the function!!! (see documentation)
                function = functionTemplate.getFunction();
                if (inputParams != null) {
                    input = function.getImportParameterList();
                    setInput(input, inputParams);
    if ( tableParams != null && tableParams.length > 0 ){
    JCO.ParameterList tables = function.getTableParameterList();
    setTables(tables, tableParams); }
                // make the call to ABAP. All input parameter are already set
                // in the function.
                connection.execute(function);
                return handleResponse(function, packageName);
            finally {
                 if (connection!=null) {
                      JCO.releaseClient(connection);
                 functionTemplate  = null;
                 function = null;
                 input = null;
                 connection = null;

    It looks like I am the only one that is having similar issues.
    After some investigation, this issue is being maxcimized by the load (120k transaction per ghour).
    The leak is visible in the C heap.
    Antoine

Maybe you are looking for

  • How can I set a file to hidden

    Hi all How can I set a file to hidden from within Java. This is what I have tried so far but with out any luck     String[] cmd = new String[3];     cmd[0] = "cmd.exe";     cmd[1] = "attrib +h";     cmd[2] = "\""+"C:/program files/Licence.xml"+"\"";

  • Problem in VL31N

    Dear QM Expert, My user requirement is inspection in against inbound delivery (vl31n), For fulfill this requirement i change configuration, Assign inspection type in material master(01) Assign Inspection Lot Origin (01) to Delivery Type. and  Assign

  • How to test the rule if multiline container is passing to the task?

    Hi Experts,                   I am working on leave workflow. I have to get the approvers based on no of days of leave and leave type. I am getting these details in ITEMS_TAB internal table. I am passing this table to a rule. Now my problem is when I

  • Windows 7 build 7601 this copy of windows is not genuine how to solve this

    my new pc is showing the messege windows 7 Build 7601 This copy of Windows is not genuine how to solve the issue

  • Advanced Queuing between 2 databases

    Hi, We want to use Oracle Advance Queuing to send a message from a source Database (transactional) to a Reporting database On a particular event on a record in the source database, we want to enqueue the record's code on a Queue in the target databas