0

I am re-writing my JCO2 code to JCO3 code to run on a 64 bit windows server. When I try to read my SAP table with the JCO3 code it is returning an empty table. However when I run the JCO2 code I have 2 records in the table.

Here is a snipet of my JCO3 code:


try
 {
System.out.print("after try");
try {
    ABAP_AS2 = JCoDestinationManager.getDestination(ABAP_MS);
    }
    catch (Exception e) {
        ABAP_AS2 = null;
        System.out.print("ABAP_AS2 = null");
    }
    ABAP_AS2.ping();
JCoFunction function = ABAP_AS2.getRepository().getFunction("ZPC_RFC_READ_QMLN");
        function.execute(ABAP_AS2);
        System.out.println("STFC_CONNECTION finished:");
        JCoTable return_table = function.getTableParameterList().getTable("DATA");   
        Sytem.out.println("get table");
   int records = return_table.getRow();
        System.out.println(records);

The result is records = 0. When I run the JCO2 code on the same table the result is records = 2.

Please tell me what I am missing.

Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120

1 Answers1

1

Apparently you haven’t read the API documentation:

`int getRow()`
Returns the current row number. The first row number is 0, the second is 1, and so on.

You probably want to switch to getNumRows().

vwegert
  • 18,093
  • 3
  • 33
  • 54
  • Thank you. So I changed the code to getNumRows() and I still get records = 0. When I try to execute the code: for (int i = 0; i < return_table.getNumRows(); i++) - (which comes directly from the API documentation) it doesn't enter the loop. Any other ideas? – user3654038 May 21 '14 at 20:38
  • Have you used the remote debugging facility to find out whether the function module recieves and returns the correct values in the first place? – vwegert May 22 '14 at 07:08
  • I don't know your RFC. Are there any import parameters you should have set? Something like `function.getImportParameterList().setValue("DATUM_VON", datum_von);` Or is there any return code you can check? `String rc = function.getExportParameterList().getString("RETURNCODE");` – rawdog Jun 13 '14 at 13:50
  • Thank you all for the comments. It seems my problems was with the install of the JCO on the server. :( My code was not the problem. – user3654038 Jun 18 '14 at 13:53