SAP JCo3 table empty although connected

293 Views Asked by At

Hi I am using SAP JCo3 connector along with .dll file provided with the jar. the destination is successfully connected. My problem is that when I am doing the function.execute(destination) the function.getTableParameterList().getTable("PART_LIST") returns an empty table with zero rows.

My code to achieve the connectivity is as below:

JCoDestination dest  = JCoDestinationManager.getDestination("EOMP");
dest.ping();
JCoRepository repo=  dest.getRepository();
JCoFunctionTemplate ftemplate = repo.getFunctionTemplate("Z_BAPI_GET_ESO_PART");
JCoFunction function = ftemplate.getFunction();
JCoParameterList importParams = function.getImportParameterList();
        
importParams.setValue("ESO","R1S00444");
importParams.toXML();
        
function.execute(dest);
       
JCoParameterList tableParamList=function.getTableParameterList();
JCoTable table=tableParamList.getTable("PART_LIST");
2

There are 2 best solutions below

0
On

I had the same phenomenon a few days back ...

After a while, I noticed that the parameter to be passed - if it is a char - must be as long as the size of the field.

Your field length is 12 and is char. If you call your function directly in SAP, you pass on e.g. 1234567891 and get your desired result.

However, if you call it from the RFC connection, you must prepare the record 001234567891.

Look up the DB-table. Try it with the given example in the table.

0
On

I recommend to debug your ABAP code. If it would fill in some rows to this PART_LIST table you would also get them at Java side. There is no obvious error in your Java code, except importParams.toXML() is superfluous and also dest.ping() is not needed.