Skip to Content
author's profile photo Former Member
Former Member

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Jun 30, 2007 at 11:35 PM

    You might benefit by reading the JCO pdf delivered with the jco download from

    Usually it is easier to define the structure and the function interface as an SAP function even if there is no body (abap to java). This means that the JCO will read correctly all the metainformation about the function. You then call the function as an RFC specifying the host...

    Have fun...

    In your case I would read carefully the example (getting the company code info etc...)

    It shows how to manipulate the table returned by ABAP...

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.