Skip to Content
Former Member
Jun 26, 2007 at 09:23 PM

JCO - Java to ABAP (JCO.Server could not marshall tables exception)


I have a simple program ABAP function module making a call to Java. From Java I need to return a table of results. The table is defined in the ABAP dictionary. Esentially it is made up of a simple 3 field structure.

I have tried many ways of packaging the table data in Java but have not been successful. In all cases I get either a class cast exception or cannot marshal tables exception.

In the case I don't get any exceptions the data is all garbled up.

Pls help.

I have posted the java code snippet for both the repository and the data packaging.


Repository code:


JCO.MetaData fmeta = new JCO.MetaData("searchForObject");

fmeta.addInfo("OBJLIST", JCO.TYPE_TABLE, 144, 0, 0, 0, "ZBBP_OBJ_LIST");

fmeta.addInfo("QUERYSTRING", JCO.TYPE_CHAR, 255, 0, 0, JCO.EXPORT_PARAMETER, null);

fmeta.addInfo("QUERYNAME", JCO.TYPE_CHAR, 32, 0, 0, JCO.EXPORT_PARAMETER, null);


JCO.MetaData tmeta = new JCO.MetaData("ZBBP_OBJ_LIST");

tmeta.addInfo("ZRFX_STRUCT", JCO.TYPE_STRUCTURE, 128);


JCO.MetaData smeta = new JCO.MetaData("ZOBJ_STRUCT");

smeta.addInfo("NAME", JCO.TYPE_CHAR, 32, 0, 0);

smeta.addInfo("AMOUNT", JCO.TYPE_CHAR, 32, 0, 0);

smeta.addInfo("CURRENCY", JCO.TYPE_CHAR, 3, 0, 0);



Handle Request Code:


protected void handleRequest(JCO.Function function)


JCO.ParameterList input = function.getImportParameterList();

JCO.ParameterList output = function.getExportParameterList();

JCO.ParameterList tables = function.getTableParameterList();

if (function.getName().equals("searchForObj"))


JCO.Table rfx = tables.getTable("OBJLIST");


// set values

JCO.Record struct = (JCO.Record)repository.getStructureDefinition("ZOBJ_STRUCT");

struct.setValue("Name1", "NAME");

struct.setValue("100", "AMOUNT");

struct.setValue("USD", "CURRENCY");

rfx.setValue(struct, 1);

output.setValue("Query Name 11","QUERYNAME");

output.setValue("Select *","QUERYSTRING");




Pls help.