JCo code.

I am using JCo 3, but I have problem to use it. Even I tested RFC using the JRfcTest tool successfully, but when I use JCo to getDestination, and then destination.getRepository(), I always get exception as below:
    message: Communication with RFC server programs is not supported with JCo standalone 3.0.1 (2008-10-21)
    Return code: RFC_INVALID_PARAMETER(19)
    error group: 101
    key: RFC_ERROR_PROGRAM
I don't know what that means. I am following the examples provided by JCo library, but it's not working.
Can any expert give me some idea what I am missing?
Thanks a lot!
Ken

Have you tried upgrading to 3.0.2
Read SAP Note 1310832 - SAP Java Connector Release 3.0.2
Regards
Juan

Similar Messages

  • Error in Running JCO code in Netweaver Devloper Studio

    Hi,
    I have written a simple java program to get data from SAP using JCO code. It get compiled successfuly but when I run it, It gives the following error :
    java.lang.NoClassDefFoundError
         at com.sap.mw.jco.MiddlewareJRfc$Client.connect(MiddlewareJRfc.java:798)
         at com.sap.mw.jco.JCO$Client.connect(JCO.java:2829)
         at com.sap.test.SAPPoDetailMain.getPODetail(SAPPoDetailMain.java:39)
         at com.sap.test.SAPPoDetailMain.main(SAPPoDetailMain.java:77)
    Exception in thread "main"
    Is there any way in which I can run this code in Netweaver Devloper Studio.
    Thanks
    Naresh

    Hi Stefan,
    I have tried that but still it is giving the same. I am using Generated proxied to call function module. Once again copying the detailed error :
    java.lang.UnsatisfiedLinkError: no CpicNative in java.library.path
         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1491)
         at java.lang.Runtime.loadLibrary0(Runtime.java:788)
         at java.lang.System.loadLibrary(System.java:834)
         at com.sap.mw.rfc.api.RfcApi.initializeDLL(RfcApi.java:1285)
         at com.sap.mw.rfc.api.RfcApi.<clinit>(RfcApi.java:1299)
         at com.sap.mw.jco.MiddlewareJRfc.<clinit>(MiddlewareJRfc.java:228)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:141)
         at com.sap.mw.jco.JCO.<clinit>(JCO.java:630)
         at com.sap.test.SAPPoDetailMain.getPODetail(SAPPoDetailMain.java:26)
         at com.sap.test.SAPPoDetailMain.main(SAPPoDetailMain.java:79)
    java.lang.NoClassDefFoundError
         at com.sap.mw.jco.MiddlewareJRfc$Client.connect(MiddlewareJRfc.java:798)
         at com.sap.mw.jco.JCO$Client.connect(JCO.java:2829)
         at com.sap.test.SAPPoDetailMain.getPODetail(SAPPoDetailMain.java:41)
         at com.sap.test.SAPPoDetailMain.main(SAPPoDetailMain.java:79)
    Exception in thread "main"
    Thanks
    Naresh

  • Cannot create client error with sample SAP JCO code

    Hi,
    I am encountering the following error when trying to connect to a R/3 system using the WAS 6.40 on my laptop. I have cut and pasted the Example1 code from the SAPJCO into my NetWeaver developer studio IDE.
    java.lang.UnsatisfiedLinkError: no CpicNative in java.library.path
         at java.lang.ClassLoader.loadLibrary(Unknown Source)
         at java.lang.Runtime.loadLibrary0(Unknown Source)
         at java.lang.System.loadLibrary(Unknown Source)
         at com.sap.mw.rfc.api.RfcApi.initializeDLL(RfcApi.java:1285)
         at com.sap.mw.rfc.api.RfcApi.<clinit>(RfcApi.java:1299)
         at com.sap.mw.jco.MiddlewareJRfc.<clinit>(MiddlewareJRfc.java:228)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at com.sap.mw.jco.JCO.<clinit>(JCO.java:630)
         at com.sap.mw.jco.support.JRfcTest.correctProperties(JRfcTest.java:1043)
         at com.sap.mw.jco.support.JRfcTest.initCall(JRfcTest.java:1072)
         at com.sap.mw.jco.support.JRfcTest.runConnectionTest(JRfcTest.java:735)
         at com.sap.mw.jco.support.JRfcTest.main(JRfcTest.java:202)
    Cannot create client, error message:
    java.lang.NoClassDefFoundError occured:
       Message:null
    I have a system user defined in R/3 but still this isn't working. I am new to Java so any light you could shed would be greatly appreciated.
    Cheers and TIA,
    Rich

    The unsatisfied link error should be because sapjco.jar cannot link to the sapjco.dll.
    I tried to simulate the problem by
    1) Opening a java perspective.
    2) Create a new 'java' project.
    3) Add libraries sapjco.jar from the path <Drive>:\Program Files\SAP\JDT\eclipse\plugins\com.sap.mw.jco\lib
    You will see sapjcorfc.dll in this path
    4)Add a new class file ,Wrote a sample jco code and executed and it worked..
    The key is to have the sapjcorfc.dll in the same directory as sapjco.jar
    I hope this helps

  • I18n Struts Jco Code in Windows English and Polish System

    I am working on Struts ,SAP-JCO .
    This is i18n application running on Tomcat.
    I have designed my application in UTF8 charset.
    When Saving the polish characters from application they are saved into SAP Database properly.
    Before Saving i am doing following String modifications.
    The same code doesn't work on Tomcat Server on Windows English System.Here the Polish characters( ąęćłóńśźż ) are saved as #########.
    What would be cause for this.
    What changes i need to do in my code to work on both English And Polish Windows (Tomcat Server)
    strConvertedMessage = new String(strText.getBytes("UTF8"), "UTF8");
    inputTable.setValue(strConvertedMessage,"TABLENAME");

    Yes while retring the polish content from SAP following chnage is done between English and Polish Windows Systems.
    English Windows OS
    strFormatedMessage =new String(strMessage.getBytes("ISO-8859-1"), "ISO-8859-2");
    Polish Windows OS
                        strFormatedMessage=null;
                        strFormatedMessage = new String(strMessage.getBytes("UTF-8"), "UTF-8");

  • Webservice in NWDS having JCO code

    Hi All,
    I have a requirement which is to create a JAVA web service in NWDS which can service a .NET internet Application take some data from .NET and
    put it into the SAP by calling a RFC Module...
    I have written a class which has two methods
    it simply connects to SAP & processes the RFC Module...
    This class works fine if i run it as a
    standalone java application with a main
    method.. <b>but it fails</b> when i deploy it as a web service and try to run it through a Standalone
    Client ... it is able to create the
    WSDL and the methods are also visible but it
    fails from the code where JCO logic starts...
    I am getting the error message as
    <b>Warning ! Protocol Implementation [com.sap.engine.services.webservices.jaxrpc.
    wsdl2java.features.builtin.MessageIdProtocol] could not be loaded (NoClassDefFoundError) !
    Error Message is :com/sap/guid/GUIDGeneratorFactory
    javax.xml.rpc.soap.SOAPFaultException: com/sap/mw/jco/JCO$Exception
         at com.sap.engine.services.webservices.jaxrpc.wsdl2java.soapbinding.MimeHttpBinding.buildFaultException(MimeHttpBinding.java:651)
         at com.sap.engine.services.webservices.jaxrpc.wsdl2java.soapbinding.MimeHttpBinding.processDocumentFault(MimeHttpBinding.java:742)
         at com.sap.engine.services.webservices.jaxrpc.wsdl2java.soapbinding.MimeHttpBinding.call(MimeHttpBinding.java:1240)
         at proxy.ConfigBindingStub.setCustomerMasterRFC(ConfigBindingStub.java:81)
         at proxy.ConfigBindingStub.setCustomerMasterRFC(ConfigBindingStub.java:112)
         at proxy.DealerClient.main(DealerClient.java:25)</b>
    I am using sapjco.jar in the project properties dialog box but it is not there when the EAR is generated & deployed..
    Can this be a problem ??? If yes where should i put
    this sapjco.jar
    Please help me out as i am really facing a hard time finding out the reason for this

    Hi Maksim,
    Thankyou so much maksim for the jar file path
    you had given , the first error is gone
    when i put the jar file in project
    properties.
    But i am still getting some errors
    because of the JCO library methods that
    i am using ... all other simple web services
    work fine in my system but i am getting
    following errors
    <b>javax.xml.rpc.soap.SOAPFaultException: com/sap/mw/jco/JCO
         at com.sap.engine.services.webservices.jaxrpc.
    wsdl2java.soapbinding.MimeHttpBinding.
    buildFaultException(MimeHttpBinding.java:651)
         at com.sap.engine.services.webservices.jaxrpc.
    wsdl2java.soapbinding.MimeHttpBinding.
    processDocumentFault(MimeHttpBinding.java:742)
         at com.sap.engine.services.webservices.jaxrpc.wsdl2java.soapbinding.MimeHttpBinding.call(MimeHttpBinding.java:1240)
         at proxy.ConfigBindingStub.setEclipseData(ConfigBindingStub.java:80)
         at proxy.ConfigBindingStub.setEclipseData(ConfigBindingStub.java:96)
         at com.carrier.isa.Client.main(Client.java:29)</b>
    when i put a simple code like
                    <b>JCO.Client aConnection=null;
              IRepository aRepository=null;
              try {
                   System.out.println("Creating a client");
                   aConnection=JCO.createClient(
                                                 SAP_CLIENT,
                                                 USER_ID,
                                                 PASSWORD,
                                                 LANGUAGE,
                                                 HOST_NAME,
                                                 SYSTEM_NUMBER);</b>                                             System.out.println(aConnection.toString());
              ArrayList array=new ArrayList();
              array.add("Tarun");
              array.add("Abhay");
              array.add("Sujit");
              array.add("Sandy");
              array.add("Sachin");
              returnStr=array.get(2).toString()"--"test;
              catch(Exception e)
                   e.printStackTrace();
              return returnStr;
    the code above is just a snippet of the whole .
    I have sapjco.jar in project properties in NWDS or eclipse but this jar is missing when
    i build an EAR in the Web services perspective..
    Can the missing of this jar in the
    project EAR be the cause of problem ...
    if yes let me know where should i add it ...
    Also, I created a simple java project so i
    am not having any WEB-INF folder ...
    do i need to create a web project instead ..
    Please help me as you did earlier ..
    I would be highly obliged ....

  • Exception in executing JCo code

    I am getting following exception
    Failed to get system null
    while executing following code----
    package com.sap.nwrig.demo;
    import javax.resource.ResourceException;
    import com.sap.security.api.umap.NoLogonDataAvailableException;
    import com.sapportals.portal.prt.component.*;
    import com.sapportals.portal.prt.runtime.PortalRuntime;
    import com.sapportals.portal.ivs.cg.ConnectionProperties;
    import com.sapportals.portal.ivs.cg.IConnectorGatewayService;
    //import com.sapportals.portal.ivs.cg.IConnectorService;
    import com.sapportals.connector.ConnectorException;
    import com.sapportals.connector.connection.IConnection;
    import com.sapportals.connector.execution.objects.IQuery;
    import com.sapportals.connector.execution.objects.InvalidQueryStringException;
    import com.sapportals.connector.execution.objects.QueryExecutionException;
    import com.sapportals.connector.execution.structures.IRecordMetaData;
    import com.sapportals.connector.execution.structures.IRecordSet;
    import com.sapportals.connector.metadata.CapabilityNotSupportedException;
    public class ConnectorExample extends AbstractPortalComponent
        public IConnection connection;
         IQuery query=null;
         public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
        {//docontent start
              IConnectorGatewayService cgService =
              (IConnectorGatewayService)PortalRuntime.getRuntimeResources().getService(IConnectorGatewayService.KEY);
              ConnectionProperties cp =
               new ConnectionProperties(request.getLocale(),request.getUser());
              try {
                   connection =cgService.getConnection("Pubs",cp);
              } catch (ConnectorException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (NoLogonDataAvailableException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              try {
                   query = connection.newQuery();
              } catch (CapabilityNotSupportedException e1) {
                   // TODO Auto-generated catch block
                   e1.printStackTrace();
          String qstr = "SELECT * FROM BAPI_SALESORDER_CHANGE ";
          try {
              boolean success = query.execute(qstr);
               catch (QueryExecutionException e2)
              // TODO Auto-generated catch block
                e2.printStackTrace();
                catch (ConnectorException e2)
              // TODO Auto-generated catch block
                  e2.printStackTrace();
                catch (InvalidQueryStringException e2)
              // TODO Auto-generated catch block
                   e2.printStackTrace();
              IRecordSet rs = null;
              try {
                   rs = query.retrieveRecordSet();
              } catch (ConnectorException e3) {
                   // TODO Auto-generated catch block
                   e3.printStackTrace();
              IRecordMetaData rsMD = null;
              try {
                   rsMD = rs.retrieveMetaData();
              } catch (ConnectorException e4) {
                   // TODO Auto-generated catch block
                   e4.printStackTrace();
              response.write("<table><tr>");
              int columnCount = 0;
              try {
                   columnCount = rsMD.getColumnCount();
              } catch (ConnectorException e5) {
                   // TODO Auto-generated catch block
                   e5.printStackTrace();
              for (int index = 1; index <= columnCount; index++)
                   try {
                        response.write("<th>"+ rsMD.getColumnLabel(index) + "</th>");
                   } catch (ConnectorException e6)
                        // TODO Auto-generated catch block
                        e6.printStackTrace();
                 response.write("</tr>");
                         try {
                             while (rs.next())
                                      response.write("<tr>");
                                      for (int index = 1; index <= columnCount; index++)
                                           response.write("<td>" + rs.getString(index)+ "</td>");
                                      response.write("</tr>");}
                        } catch (ConnectorException e6) {
                             // TODO Auto-generated catch block
                             e6.printStackTrace();
                        }response.write("</table>");    
                   try {
                        connection.close();
                   } catch (ResourceException e7) {
                        // TODO Auto-generated catch block
                        e7.printStackTrace();
        }//do content end
    pls help me dissolve this error

    Is "Pubs" marked as the default alias for the System?
    Sap help maybe
    http://help.sap.com/saphelp_nw04/helpdata/en/30/a0f17aacb34b108b39a96acc33da3f/content.htm
    But the error says NoLogonDataAvailableException so it must have something to do with this.
    Does your request.getUser() return a user?
    br Peter
    Message was edited by:
            Peter

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

  • Unable to create sales Order/Inquiry object using SAP JCo

    Hi All,
    Pls can you help me.
    I am using BAPI_INQUIRY_CREATEFROMDATA2 and BAPI_Trancation_commit to create Inquiry object.From my Client JCo code there is no error.I debugged the BAPI_Trasaction_commit, there is no error,  return code is 0.  But th system is not creating Inquiry object. When I try the same from SAP GUI client with exactly the same input parameters it works.
    Do I need to set any option/value to commit the Inquiry to the SAP database? How to maintain the same session between the different BAPI's. Is there any issue with Session maintainance? I would appreciate if you can provide me any sample SAP JCo code for creating a Sales Order/Inquiry.
    Thanks
    mars

    Can you put the part of your code that fill the ORDER_PARTNERS table, also you could compare your coding with [Sales order creation using BAPI|http://wiki.sdn.sap.com/wiki/display/Snippets/SalesordercreationusingBAPI] in [Community Code Gallery |http://wiki.sdn.sap.com/wiki/display/Snippets/CommunityCodeGallery] (don't forget that there is a conversion exit on the partner role, so use internal codes "AG" and "WE")
    Regards,
    Raymond

  • Jco does not commit

    Hi experts.
    I have a problem with jco. I made a jsp page including jco that calls a CBO function module(RFC). When I run the page with debug mode, commit work is executed. But it's not work non-debug mode even though I execute 'BAPI_TRANSACTION_COMMIT' on the page. I don't know why it's not work. Below code is mine.
    public String fileDocTest(String doc, String doctype)       {
      JCO.Client client = null;
      JCO.Repository rep = null;
      JCO.Function function = null;
      JCO.Function function_comm = null;
      String rstring = "";
      String docnum ="";
      String temp = "1";
      String temp1 = "SAP-SYSTEM";
      try
        client = SAPConnectionPool.getInstance().getConnection();
        rep = new JCO.Repository(repositoryName, client);
        CreateFunction crtFnc = new CreateFunction(rep);
        CreateFunction crtFnc2 = new CreateFunction(rep);
        function_comm = crtFnc.createFunction("BAPI_TRANSACTION_COMMIT");
        function = crtFnc2.createFunction("Z_1EH_UPLOAD_DOC_2");
        JCO.setMiddlewareProperty("jco.middleware.allow_start_of_programs","ftp;sapftp;sapftpa;sapkprotp;http;saphttp;saphttpa");  
        JCO.Structure imp_f_table_00 = function.getImportParameterList().getStructure("DOCUMENTDATA");
         imp_f_table_00.setValue("CPD","DOCUMENTTYPE");
         imp_f_table_00.setValue("CFPDOC","DESCRIPTION");
        JCO.Table imp_f_table_01 = function.getTableParameterList().getTable("DOCUMENTDESCRIPTIONS");
         imp_f_table_01.appendRow();
         imp_f_table_01.setValue("EN","LANGUAGE");
         imp_f_table_01.setValue("CfPDoc","DESCRIPTION");
        JCO.Table imp_f_table_02 = function.getTableParameterList().getTable("DOCUMENTFILES");
         imp_f_table_02.appendRow();
         imp_f_table_02.setValue( "1","ORIGINALTYPE");
         imp_f_table_02.setValue( "SAP-SYSTEM","STORAGECATEGORY");                            imp_f_table_02.setValue(doc,"DOCPATH");     
         imp_f_table_02.setValue(doctype,"WSAPPLICATION");
         client.execute(function);
         client.execute(function_comm);
                                JCO.ParameterList exp_f_table = function.getExportParameterList();
      catch (Exception ex)
          ex.printStackTrace(); 
          System.out.println("Caught an exception: \n" + ex);
      finally
          JCO.releaseClient(client);
          return docnum;
    FM Z_1EH_UPLOAD_DOC_2 calls a standard FM API_DOCUMENT_MAINTAIN2.
    If you have any inforamtion about JCO commit error, please let me know.
    Regards.

    Hi Nils.
    Frankly I say, I try to commit in the source code of 'Z_1EH_UPLOAD_DOC_2" fucntion like below.
      CALL FUNCTION 'API_DOCUMENT_MAINTAIN2'
           EXPORTING: pf_transaction       = 'CV01'
                      documentdata         = documentdata
                      hostname             = hostname
                      change_number        = docbomchangenumber
                      valid_from           = docbomvalidfrom
                      revision_level       = docbomrevisionlevel
                      pf_ftp_dest          = pf_ftp_dest
                      pf_http_dest         = pf_http_dest
                      CAD_MODE             = CAD_MODE
           IMPORTING: documenttype         = documenttype
                      documentnumber       = documentnumber
                      documentpart         = documentpart
                      documentversion      = documentversion
                      return               = return
          TABLES:     characteristicvalues = characteristicvalues
                      classallocations     = classallocations
                      documentdescriptions = documentdescriptions
                      objectlinks          = objectlinks
                      documentstructure    = documentstructure
                      documentfiles        = documentfiles
                      longtext             = longtexts
                      components           = components.
       if return-type is initial or return-type =  'S'.
        commit work.
        if sy-subrc = 0.
          if return-type is initial.
            return-type = 'S'.
            return-message = documentnumber.
          endif.
        else.
          call function 'BAPI_TRANSACTION_COMMIT'
            exporting
              wait = 'X'.
          if sy-subrc = 0.
            return-type = 'S'.
            return-message = documentnumber.
          endif.
        endif.
      else.
        return-type = 'E'.
      endif.
    But, it's not work too. So, I tried to commit at JCO code. Is there any kind of problem?

  • URGENT HELP !JCO RETURN structure from SAP

    Hello,
    I am working on my intern project and I got some trouble.
    I have used JDBC to access a table in Oracle(this is an independent DB)I updated a column in the table and selected all data that
    was marked as 6 based on the update(SAP needs this data). I passed the values to a JCO application,
    which connects to SAP and send the data (I presume what I'm doing is correct) to a structure in SAP.
    SAP does some internal calculations with the data and should return the data back using the same
    structure but this time with some changes on the data.
    For example the field steuk is marked as 7 if the data processing was successful and if the data
    structure wasn't successful a 6 will be return.
    The return Values should be updated in the oracle DB indicating if the transfer was successful
    or not. And next time the same data will be sent to SAP following the same path.
    Now when I look at the return getString data in Eclipse, the result seems ambiguous.I don't see the data I presumably
    sent to the SAP structure using:
    JCO.ParameterList list = function.getTableParameterList();
    JCO.Table ztable =  list.getTable("ZSAORA_RUECK");
         for (int i = 0; i < 19; i++) {
         ztable.appendRow();
         ztable.setValue(value,field name);
    Am I doing some thing wrong here??? Any Help will be highly appreciated. Codes could be sent to [email protected]
    BELOW are the codes:
    CONNECTING TO test_table in Oracle DB:
    import java.sql.*;
    public class DatabaseConnect {
         public static void main(String[] args) {
         Connection con = null;
         Statement stmt = null;
         ResultSet re = null;
         String[] ParamArray;            
            ParamArray = new String[24];
         //Properties logon;
         try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
         con = DriverManager.getConnection
    ("jdbc:oracle:thin:@226.190.0.1:1521:testdb","test","test1");
         stmt = con.createStatement ();
         stmt.executeUpdate("UPDATE test_table set steuk = 6 WHERE steuk = 5");
    ResultSet rs = stmt.executeQuery("SELECT mandt,kokrs,werks,arbpl,aufnr,vornr,ile01,"+
    "lsa01,ism01,ile02,lsa02,ism02,ile03,lsa03,ism03,"+
    "ile04,lsa04,ism04,steuk,matnr,budat,kostl,pernr,"+
    "rueckid FROM test_table where steuk =6");                              
         while (rs.next()) {
         for (int i = 1; i <= 24; i++){
         ParamArray[i-1] = rs.getString(i);
         System.out.print(rs.getString(i) + 't');
         System.out.println();                    
         } catch(Exception e) {
         e.printStackTrace();                    
         } finally {
              try
         if(stmt != null) stmt.close();
         if(con != null) con.close(); 
         } catch (Exception exception) {
              exception.printStackTrace();
         // Bapi call
         TryBapi sap = new TryBapi(ParamArray);
    BELOW IS THE JCO Code which connects to SAP and send data to the structure:
    import com.sap.mw.jco.IFunctionTemplate;
    import com.sap.mw.jco.JCO;
    public class TryBapi extends Object {     
    JCO.Client mConnection;     
    JCO.Repository mRepository;     
    OrderedProperties logonProperties;
    public TryBapi(String[] paramArray){
         try {
         logonProperties = OrderedProperties.load("/logon.properties");
         mConnection = JCO.createClient((String)logonProperties.get("jco.client.client"),
             (String)logonProperties.get("jco.client.user"),
            (String)logonProperties.get("jco.client.passwd"),
                             null,
           (String)logonProperties.get("jco.client.ashost"),
         String)logonProperties.get("jco.client.sysnr")
         mConnection.connect();
         mRepository = new JCO.Repository("SAPJCO",mConnection);
         catch (Exception ex) {
         ex.printStackTrace();
         System.exit(1);
         JCO.Function function = null;
         JCO.Table tab = null;
         try {
              function = this.createFunction("Z_UPDATE_SAORA_RUECK");
              if (function == null) {
              System.out.println("Z_UPDATE_SAORA_RUECK not found in SAP.");
              System.exit(1);
         JCO.ParameterList list = function.getTableParameterList();
              JCO.Table ztable =  list.getTable("ZSAORA_RUECK"); //inserting 24 records loop.
         for (int i = 0; i < 24; i++) {
         ztable.appendRow(); //ztable.setValue(value, field name)
         ztable.setValue("300","MANDT");
         ztable.setValue("KOKRS" + i, "KOKRS");
         ztable.setValue("WERKS" + i, "WERKS");
         ztable.setValue("ARBPL" + i, "ARBPL");
         ztable.setValue("AUFNR" + i, "AUFNR");
         ztable.setValue("VORNR" + i, "VORNR");
         ztable.setValue("ILE01" + i, "ILE01");
         ztable.setValue("LSA01" + i, "LSA01");
         ztable.setValue("ISM01" + i, "ISM01");
         ztable.setValue("ILE02" + i, "ILE02");
         ztable.setValue("LSA02" + i, "LSA02");
         ztable.setValue("ISM02" + i, "ISM02");
         ztable.setValue("ILE03" + i, "ILE03");
         ztable.setValue("LSA03" + i, "LSA03");
         ztable.setValue("ISM03" + i, "ISM03");
         ztable.setValue("ILE04" + i, "ILE04");
         ztable.setValue("LSA04" + i, "LSA04");
         ztable.setValue("ISM04" + i, "ISM04");
         ztable.setValue("STEUK" + i, "STEUK");
         ztable.setValue("MATNR" + i, "MATNR");
         ztable.setValue("BUDAT" + i, "BUDAT");
         ztable.setValue("KOSTL" + i, "KOSTL");
         ztable.setValue("PERNR" + i, "PERNR");
         ztable.setValue("RUECKID" + i, "RUECKID");
         list.setValue(ztable,"ZSAORA_RUECK");
         function.setTableParameterList(list);
         mConnection.execute(function);
         catch (Exception ex) {
         ex.printStackTrace();
         System.exit(1);
          JCO.Table codes = null;
         try {
         codes = function.getTableParameterList().getTable("ZSAORA_RUECK");
         System.out.println("Return Values starts HERE:");
         for (int i =0; i < codes.getNumRows(); i++){                 
         codes.setRow(i);
         System.out.println(codes.getString("MANDT")+ 't'+
         codes.getValue("KOKRS")+ 't'+
         codes.getString("WERKS")+ 't'+
         codes.getString("ARBPL")+ 't'+
         codes.getString("AUFNR")+ 't'+
         codes.getString("VORNR")+ 't'+
         codes.getString("ILE01")+ 't'+
         codes.getString("LSA01")+ 't'+
         codes.getString("ISM01")
    /*     codes.getString("ILE02")+ 't'+
         codes.getString("LSA02")+ 't'+
         codes.getString("ISM02")+ 't'+
         codes.getString("ILE03")+ 't'+
         codes.getString("LSA03")+ 't'+
         codes.getString("ISM03")+ 't'+
         codes.getString("ILE04")+ 't'+
         codes.getString("LSA04")+ 't'+
         codes.getString("ISM04")+ 't'+
         codes.getString("STEUK")+ 't'+
         codes.getString("MATNR")+ 't'+
         codes.getString("BUDAT")+ 't'+
         codes.getString("KOSTL")+ 't'+
         codes.getString("PERNR")+ 't'+
         codes.getString("RUECKID")       */
         catch (Exception ex) {
         ex.printStackTrace();
         System.exit(2);           
         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.");
    Message was edited by: Rudolph Emange
    Message was edited by: Rudolph Emange

    Hi Astrid,
    Thank you for your remarks. The problem I'm having is that when I do send the values to SAP using the loop:
    JCO.ParameterList list = function.getTableParameterList();
    JCO.Table ztable =  list.getTable("ZSAORA_RUECK");
         for (int i = 0; i < 19; i++) {
         ztable.appendRow();
         ztable.setValue(value,field name);
    I do expect to have(or see) some values when I do access the same table structure(This is just a structure and
    not a real table as I do understand that there is a different between a structure and a table in SAP) and
    not the field names back.In the second try and catch block:
    try {
         codes = function.getTableParameterList().getTable("ZSAORA_RUECK");
         System.out.println("Return Values starts HERE:");
         for (int i =0; i < codes.getNumRows(); i++){                 
         codes.setRow(i);
         System.out.println(codes.getString("MANDT")+ 't'+
         codes.getValue("KOKRS")+ 't'+
         codes.getString("WERKS")+ 't'+
         codes.getString("ARBPL")+ 't'+
         codes.getString("AUFNR")+ 't'+
         codes.getString("VORNR")+ 't'+
         codes.getString("ILE01")+ 't'+
         codes.getString("LSA01")+ 't'+
         codes.getString("ISM01")
    I'm trying to access the values I sent in the first try and catch block. I presume I should see some real values and not the
    field names.This is how my output looks like:
    300     KOKR     WERK     ARBPL0     AUFNR0     VORN     ILE     
    300     KOKR     WERK     ARBPL1     AUFNR1     VORN     ILE     
    300     KOKR     WERK     ARBPL2     AUFNR2     VORN     ILE     
    300     KOKR     WERK     ARBPL3     AUFNR3     VORN     ILE     
    300     KOKR     WERK     ARBPL4     AUFNR4     VORN     ILE     
    300     KOKR     WERK     ARBPL5     AUFNR5     VORN     ILE
    This does not reflect the values but the field names. Why is it this way? Does it mean that my array is wrong or I'm not at all
    sending the values. Please HELP ME OUT HERE.
    Could any one show me a better way how to send the values selected from Oracle table using perhaps an
    ARRAY to the ZSAORA_RUECK structure in SAP?
    I am trying to send the values from the select statement in the first jdbc application
    to the value field in ztable.setValue(value,  field name).
    My Regards!
    Message was edited by: Rudolph Emange

  • Exception in JCo used in EJB (WebService)

    Hi,
    I'm trying to create a webservice of an EJB that has JCo code to call an RFC.
    The EJB has no syntactical errors. The WebService generation as well as the EAR deployment is successful.
    When trying to test the WebService from WebServices Navigator, I'm getting an exception (SOAP response)
    "com.sap.engine.services.ejb.exceptions.BaseEJBException" within the (WS) method.
    What can be the possible cause for the JCo code that throws this exception when running in an EJB?
    I tried the same method from a standalone JCo Client class and it connects the RFC successfully.
    Also when the definition of the method is empty with only one statement as return "hai"; then webservice has no errors.
    This is my code... only with "mConnection.connect();" throwing the exception
    import com.sap.mw.jco.*;
    public class JCo_Connect extends Object {
      JCO.Client mConnection;
      JCO.Repository mRepository;
      public JCo_Connect() {
        try {
          // Change the logon information to your own system/user
          mConnection =
            JCO.createClient("001", // SAP client
              "<userid>",                  // userid
              "****",                         // password
              "en",                             // language
              "<hostname>",            // application server host name
              "00");                           // system number
          mConnection.connect();
          mRepository = new JCO.Repository("SAP", mConnection);
        catch (Exception ex) {
          ex.printStackTrace();
          System.exit(1);
        mConnection.disconnect();
      public static void main (String args[]) {
        JCo_Connect app = new JCo_Connect();
    Any help is highly appreciated.
    Thanks in advance.
    Regards,
    Vijay Kalyan G.

    It seems that your code is throwing a runtime exception that you don't catch. So the session bean throws an BaseEJBException.
    Try to catch full Exceptions in the EJB code and throw a new EJBException with the full trace, so you can look for the real cause.
    try {
       <jco code>
    } catch (Exception e) {
       throw new EJBException(e.getLocalizedMessage(), e);
    Regards.

  • JCO vs aRFC

    Hi all,
    I want to implement communication between my web dynpro and an R3 backend system. I've done this before, but i'm wondering about the technique to use.
    In the article "Effective Web Dynpro - Adaptive RFC Models" I found the following and i quote:
    "<i>SAP strongly recommends using the Adaptive RFC Adapter instead of implementing another technique for accessing RFCs based on the JCo communication layer.</i>"
    Is it really better to use aRFC instead of using plain JCO code directly? (JCO.Function..getImportParameterList(), ... )
    I think it is much more cleaner when using the plain JCO way instead of the aRFC way. With aRFC, even for a simple BAPI you receive lots of generated classes and i think it just looks messy.
    Am i wrong when i think that plain JCO has also better performance than aRFC?
    Kind regards,
    J.

    Joren,
    <i>So as long as i dont mind doing the low level JCO programming in which i specify the names for the parameters and structures and so on... there's nothing wrong with using JCO from Web Dynpro too. Maybe EC is a good way for going for the in between (between plain JCO and ugly model aRFC) aproach...</i>
    It depends what to call "ugly"
    For me JCo is not the best API, it's hardly an OOP but rather C-style like. Though, not surprising, because it's in fact same libs for Java and C and you may use JCo from native applications developed in C or other languages.
    <i>The WS approach is needed because we need to call R3 from existing J2EE application and we dont need to write new code for calling a WS... I think that is the only advantage of a WS, you can call it from everywhere like just any other Web Service...</i>
    I'd rather try SAP-EC (it generates typed wrappers). Or JCA if you talk about J2EE applications (like EJB or WAR projects). Anyway, it's up to you -- the only thing to note is that A-RFC available only to WD applications.
    <i>Suppose i would still implement it with aRFC, what is the best way to do context binding here? Directly from view context to component context to model context? so the model context will be filled automatically...
    Or is it better to do the fillin of the model context manually via an intermediate node in the component context?</i>
    Typically you create model nodes based on A-RFC in component controller, then uses these nodes from view controller via context mapping. Just to separate view and controller parts. By the way, try to right-click on your component (or component controller, I do not remeber exactly) and apply "Service" template. You'll be surprised how many code is autogenerated on your behalf
    Valery Silaev
    SaM Solutions
    http://www.sam-solutions.net

  • Is it possible to Trace(Debugging) JCO request from the RFC?

    hi abap gurus.
    I am calling the rfc using jco code.
    i want to trace the request, means When the jco code execute it call the rfc.i want to trace out the values coming from java program in my abap editor.
    Thanks for ur valuable replies
    lakshman.
    save a life by sending information.
    www.help2patients.wordpress.com.

    check the system calls, i mean calls stack , may be you get some hint there.
    I never checked it.check it once.
    I am surprised to see JCO questions in ABAP forum. anyway some part related to ABAP.

  • EP6 SP2 Jco / System Alias Question

    Hi all,
    I'm developing a number of Iviews on an EP6 SP2 system connected to a 4.6C box.  I have two problems that I'd be grateful for some help with.
    1) How do I make use of the System Aliases set up in the portal via Jco ?
    I know I can use the direct connection
    JCO.createClient("001", // SAP client
              "<userid>", // userid
              "****", // password
                 "EN", // language                               
                    "<hostname>", //      
              "00"); // system number
    but it would be much easier if I could use the configured System Alias called "UKSAP" which has been set-up in each Portal box.
    2) I believe that EP6 SP2 will not require connection pooling in the jco code. Is this correct ?
    Cheers
    Richard

    Hi,
    We are trying to do pretty much the same thing you are, I am trying to get my Java iview to use the System Alias to connect to an R/3 JCO destination.
    Could you elaborate on your findings in this regard. I am currently getting the following error : "Target for system alias SAP_R3_HumanResources not found in system landscape"
    I have entered the connection info for this target into the jcoDestinations.xml and I've created a system in the portal with the alias SAP_R3_HumanResources...
    Thanks in advance,
    Mukta Pathak

  • Creating Purchase Info Record in SAP using JCO

    I am trying to create a Purchase Info Record (ME11) in SAP using the below JCo code:
    It executes without fail and throws no error, but i am not able to get the newly created info record in SAP. In ME13 it says info record not found. Can i know what am i missing?
    I am using these FMs :
    1. ME_INITIALIZE_INFORECORD
    2. ME_DIRECT_INPUT_INFORECORD
    3. ME_POST_INFORECORD
    IFunctionTemplate ft1 = mRepository.getFunctionTemplate("ME_INITIALIZE_INFORECORD");
        JCO.Function function1 = ft1.getFunction();
        mConnection.execute(function1);
        IFunctionTemplate ft = mRepository.getFunctionTemplate("ME_DIRECT_INPUT_INFORECORD");
        JCO.Function function = ft.getFunction();
        JCO.ParameterList importparams =function.getImportParameterList();
        //  Setting HeadData Structure Information
        JCO.Structure headStructure = importparams.getStructure("I_EINA");
        //headStructure.setValue("105","MANDT");
        //headStructure.setValue("5300259768", "INFNR");
        headStructure.setValue("MYPART0006", "MATNR");     
        //headStructure.setValue("MYPART0006", "IDNLF");
        headStructure.setValue("100002","LIFNR");
        headStructure.setValue("10000","MATKL");
        headStructure.setValue("KGS","MEINS");
        headStructure.setValue("1","UMREZ");
        headStructure.setValue("1","UMREN");
        headStructure.setValue("SG","URZLA");
        headStructure.setValue("KGS","LMEIN");
        //headStructure.setValue("0000005300259768","URZZT");
        JCO.Structure headStructure1 = importparams.getStructure("O_EINA");
        //headStructure1.setValue("105","MANDT");
        //headStructure1.setValue("5300259768", "INFNR");
        headStructure1.setValue("MYPART0006", "MATNR");    
        //headStructure1.setValue("MYPART0006", "IDNLF");
        headStructure1.setValue("100002","LIFNR");
        headStructure1.setValue("10000","MATKL");
        headStructure1.setValue("KGS","MEINS");
        headStructure1.setValue("1","UMREZ");
        headStructure1.setValue("1","UMREN");
        headStructure1.setValue("SG","URZLA");
        headStructure1.setValue("KGS","LMEIN");
        //headStructure1.setValue("0000005300259768","URZZT");
        System.out.println("General Data Set");
        JCO.Structure purchaseDataStructure = importparams.getStructure("I_EINE");
        //purchaseDataStructure.setValue("105","MANDT");
        //purchaseDataStructure.setValue("5300259768", "INFNR");
        purchaseDataStructure.setValue("1000","EKORG");
        purchaseDataStructure.setValue("1000", "WERKS");
        purchaseDataStructure.setValue("003","EKGRP");
        purchaseDataStructure.setValue("USD","WAERS");
        purchaseDataStructure.setValue("3","APLFZ");
        purchaseDataStructure.setValue("1","PEINH");
        purchaseDataStructure.setValue("1","BPUMZ");
        purchaseDataStructure.setValue("1","BPUMN");
        purchaseDataStructure.setValue("1000","EFFPR");    
        purchaseDataStructure.setValue("0001","BSTAE");    
        purchaseDataStructure.setValue("100000","NETPR");
        purchaseDataStructure.setValue("X","KZABS");
        JCO.Structure purchaseDataStructure1 = importparams.getStructure("O_EINE");
        //purchaseDataStructure1.setValue("105","MANDT");
        //purchaseDataStructure1.setValue("5300259768", "INFNR");
        purchaseDataStructure1.setValue("1000","EKORG");
        purchaseDataStructure1.setValue("1000", "WERKS");
        purchaseDataStructure1.setValue("003","EKGRP");
        purchaseDataStructure1.setValue("USD","WAERS");
        purchaseDataStructure1.setValue("3","APLFZ");
        purchaseDataStructure1.setValue("1","PEINH");
        purchaseDataStructure1.setValue("1","BPUMZ");
        purchaseDataStructure1.setValue("1","BPUMN");
        purchaseDataStructure1.setValue("1000","EFFPR");       
        purchaseDataStructure1.setValue("0001","BSTAE");       
        purchaseDataStructure1.setValue("100000","NETPR");
        purchaseDataStructure1.setValue("X","KZABS");
        mConnection.execute(function);
        IFunctionTemplate ft2 = mRepository.getFunctionTemplate("ME_POST_INFORECORD");
        JCO.Function function2 = ft2.getFunction();
        JCO.ParameterList importparams2 =function2.getImportParameterList();
        importparams2.setValue("MYPART0006", "I_MATNR");
        importparams2.setValue("MYPART0006", "O_MATNR");
        mConnection.execute(function2);
    Edited by: rs_d123 on Dec 17, 2011 10:46 AM
    Edited by: rs_d123 on Dec 17, 2011 10:46 AM

    If i give this much code then it throws an error
    Exception in thread "main" com.sap.mw.jco.JCO$Exception: (104) RFC_ERROR_SYSTEM_FAILURE: Enter Purch. group :
    I have already set the purchase group in the code: EKGRP as 003. Dont know why its still asking for purchase group.
                JCO.Repository mRepository;
             mRepository = new JCO.Repository("SAPConnection", mConnection);
             System.out.println(" Repository Created ");
             IFunctionTemplate ft1 = mRepository.getFunctionTemplate("ZME_INITIALIZE_INFORECORD");
             JCO.Function function1 = ft1.getFunction();
             mConnection.execute(function1);
             IFunctionTemplate ft = mRepository.getFunctionTemplate("ZME_DIRECT_INPUT_INFORECORD");
             JCO.Function function = ft.getFunction();
              JCO.ParameterList importparams =function.getImportParameterList();
              //  Setting HeadData Structure Information
              JCO.Structure headStructure = importparams.getStructure("I_EINA");
              headStructure.setValue("MYPART0006", "MATNR");          
              headStructure.setValue("0000100002","LIFNR");
              headStructure.setValue("000010000","MATKL");
              headStructure.setValue("KGS","MEINS");
              headStructure.setValue("1","UMREZ");
              headStructure.setValue("1","UMREN");
              headStructure.setValue("SG","URZLA");
              headStructure.setValue("KGS","LMEIN");
              System.out.println("General Data Set");
              JCO.Structure purchaseDataStructure = importparams.getStructure("I_EINE");
              purchaseDataStructure.setValue("1000","EKORG");
              purchaseDataStructure.setValue("1000", "WERKS");
              purchaseDataStructure.setValue("003","EKGRP");
              purchaseDataStructure.setValue("USD","WAERS");
              purchaseDataStructure.setValue("1","APLFZ");
              purchaseDataStructure.setValue("1","PEINH");
              purchaseDataStructure.setValue("1","BPUMZ");
              purchaseDataStructure.setValue("1","BPUMN");
              purchaseDataStructure.setValue("1000","EFFPR");          
              purchaseDataStructure.setValue("0001","BSTAE");          
              purchaseDataStructure.setValue("1000","NETPR");
              purchaseDataStructure.setValue("X","KZABS");
              mConnection.execute(function);
             IFunctionTemplate ft2 = mRepository.getFunctionTemplate("ZME_POST_INFORECORD");
             JCO.Function function2 = ft2.getFunction();
              JCO.ParameterList importparams2 =function2.getImportParameterList();
              importparams2.setValue("MYPART0006", "I_MATNR");     
              mConnection.execute(function2);
              System.out.println("Execution Completed");
    Edited by: rs_d123 on Dec 19, 2011 9:04 AM

Maybe you are looking for

  • More generic overlays in print module

    Currently there's a way to place the identity plate on images in the print module, but it could use some work. Here are some additional features I'd like to see: Instead of using the specific identity plate as overlay, the print module should use mor

  • IOS 5: will I be able to download it without a connection to iTunes as I don't have a computer at the moment?

    I have an iPad 2 and want iOS5 when it comes out. But I just gave my MBP to my son who is in programming and needed it desperately.  Will I be able to download iOS5 without a physical connection to iTunes, which I don't have now? Thanks. Tom

  • Using Apple TV for the first time: STUMPED

    Hi there I bought an apple tv (with the cords) recently and have tried to set it up. I basically just plugged it into the tv using the HDMI cable and have put the tv on the correct input but nothing shows.. or happens.. Is there a button i am suppose

  • Load external swf by .extension and get totalFrames

    What I am trying to achieve is dragging and droping a swf into this app while trace its totalframes. But no luck yet, cant seem to ge the file.extension to be loaded. code so far: package           import flash.display.Sprite;           import flash.

  • Fileadapter polling help plz

    Hi evry one i am new to BPEL and i am in need of file adapter functionality. I have a folder which has files of naming convention NSD 123-222 090714T01:23:23 if i suppose i have some hundred files in that folder and i am pointing the file adapter to