cancel
Showing results for 
Search instead for 
Did you mean: 

Provide Table as Function Parameter in Outbound-Server

Former Member
0 Kudos

Hello,

we successfully set up an JCO Outbound Server to communicate with R/3 4.7.

First we defined a custom Repository which knows a function with one parameter only. I can call that function from SAP and get the result as an import parameter in the outbound RFC call.

Now I'd like to provide a table as one of the parameters of that function located on the outbound J2EE component.

My first idea was:

CALL FUNCTION 'STFC_FOO' DESTINATION
  'MYSERVICE_OUTBOUND'
  IMPORTING
    message        = message
   TABLES
    xmlcontent_tab = xmlcontent_tab.

The table type of xmlcontent_tab is defined.

But how do I define that table and parameter on the opposite side repository with JCO?

I use the JCO.MetaData.addInfo() interface to define the function. That looks like:

fmeta.addInfo("MESSAGE", JCO.TYPE_CHAR, 1000, 0, 0, JCO.EXPORT_PARAMETER, null);
fmeta.addInfo("XMLCONTENT_TAB", JCO.TYPE_TABLE,0 , 0, 0, JCO.EXPORT_PARAMETER, tmetaXml);

tmetaXml is defined as well:

JCO.MetaData tmetaXml = new JCO.MetaData("ES_XMLIMPORT");
tmetaXml.addInfo("ES_XMLLINE", JCO.TYPE_BYTE, ROWLENGTH);

I was wondering if there is a Flag called JCO.TABLE_PARAMETER but there is none.

How becomes the paramater a table parameter? Given the above, I get null when I ask the function for

func.getTableParameterList()

naturally...

But I can ask for

func.getExportParameterList().getTable("XMLCONTENT_TAB")

and get the table. But I believe that way the table is not stored correctly to be passed to SAP, right?

Like that the SAP program containing the statement

TABLES tab = tab1

like above crashes when casting the import parameter (export on J2EE side) to a table parameter.

When I put


...
IMPORTING
...
xmlcontent_tab = xmlcontent_tab

the program runs without exception but I get no data from the table, which was still there on the J2EE side.

So, how do I provide a table as parameter in the Outbound JCO server? Any idea? Please can you also point me to the correct Metadata definition for tables? I think that's one of my mistakes.

Thanks

Carsten

Message was edited by: Olaf Zschiedrich

Message was edited by: Olaf Zschiedrich

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I solved the issue on my own. For everyone else who is having this question.

Tables have no specific direction.

Therefore, the

int flags

parameter of JCOMetaData.addInfo() has to be 0. It's that simple.

The definition has to look like


...
fmeta.addInfo("TABLEPARAM", JCO.TYPE_TABLE, 144, 0, 0, 0, "TABLE");
repository.addFunctionInterfaceToCache(fmeta);
JCO.MetaData smeta  = new JCO.MetaData("TABLE");
smeta.addInfo("ROW",  JCO.TYPE_BYTE,  ROWLENGTH,  0, 0);
repository.addStructureDefinitionToCache(smeta);
...

Additionaly, the reference to the table/structure defnition has to be made by the name (String). Since the signature of addInfo expects an Object at this point, I was confused whether the meta object for the table definition has to be passed as the parameter.

Given that definition one may ask the JCO.Function interface for its table parameters (getTableParameterList()) and populate the data to the table.

And since tables are bidirectional that's total logical. However, some nice documentation in the JCO API doc would have made it much easier

But, an example can be found ein Example5.java of the sapjco-ntintel-2.1.3.zip distribution.

Carsten