cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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);

repository.addFunctionInterfaceToCache(fmeta);

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

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

repository.addStructureDefinitionToCache(tmeta);

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);

repository.addStructureDefinitionToCache(smeta);

*****************************************************

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");

rfx.appendRows(3);

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

You might benefit by reading the JCO pdf delivered with the jco download from sapservice.com....(free)....

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