cancel
Showing results for 
Search instead for 
Did you mean: 

Handling SAP deep structure via JCo

Former Member
0 Kudos

Hello-

I have an RFC enabled function module in my ECC 6 system that I'd like to call using the JCo API's. I have read conflicting materials on whether this is even possible or not. Can anyone confirm if it is possible or not, and if you have a general description of how you handled it with the Java code it would be much appreciated. I am an experienced SAP developer who is delving into JCo for the first time.

Thanks,

Andy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Sorry, in my haste I left out the most important part. One of the output TABLES parameters is a deep structure in SAP and that is the part I'm looking to figure out.

Thanks!

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Andy

Could you please clarify your question a little bit? What is the problem exactly with JCo API? The API allows to invoke any BAPI FM with complicated Import/Export parameters.

BR, Sergei

Former Member
0 Kudos

Hi Sergei-

My biggest concern is how to define the deep structure in the java code. In essence, I have a table definition that has fields where some are regular scalar fields, and other fields that contain tables.

From what I can tell, I can use hash maps to accomplish this, or alternatively I can declare the table as an array where some of the cells in the array contain other arrays. I apologize for not being more clear with my line of questioning, I think part of that is because I'm not sure exactly how to ask the right question.

If anyone has an example (a code snippet) where they handle calling a remote enabled function in SAP that contains a deep structure as a parameter using JCo and could share the Java code with how they handled it I would appreciate. Even pseudo code would be fantastic.

Thank you,

Andy

Former Member
0 Kudos

Hi Andy

Here is the JCo API Javadocs: http://www.huihoo.org/openweb/jco_api/

Code could be like the following (I assume output table):

JCO.Client client;

/* code for ABAP connection and getting the client here*/

JCO.Repository myRepository = new JCO.Repository("Test", client);

JCO.IFunctionTemplate ft = myRepository.getFunctionTemplate(functionName);

JCO.Function function = ft.getFunction();

/* invoke function here */

JCO.Table jcoTable = function.getTableParameterList().getTable(tableName);

for (int i = 0; i < jcoTable.getNumRows(); i++) {

jcoTable.setRow(i);

// get value of the field <fieldName>: it could be anything:

JCO.Table jcoTable = jcoTable.getTable(<field name>);

// or JCO.Structure jcoTable = jcoTable.getStructure(<field name>);

// or JCO.Field jcoField = jcoTable.getField(<field name>);

// go ahead with the field: a) get plain value or b) iterate over its rows if it's a table again

}

// close the connection

...

BR, Sergei

Edited by: Siarhei Pisarenka on Jun 4, 2009 3:50 PM

Former Member
0 Kudos

Sergei-

Thank you very much. Your reply was extremely helpful.

Regards,

Andy

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Andy

Here is the JCo API Javadocs: http://www.huihoo.org/openweb/jco_api/

Code could be like the following (I assume output table):

JCO.Client client;

/* code for ABAP connection and getting the client here*/

JCO.Repository myRepository = new JCO.Repository("Test", client);

JCO.IFunctionTemplate ft = myRepository.getFunctionTemplate(functionName);

JCO.Function function = ft.getFunction();

/* invoke function here */

JCO.Table jcoTable = function.getTableParameterList().getTable(tableName);

for (int i = 0; i < jcoTable.getNumRows(); i++) {

jcoTable.setRow(i);

// get value of the field <fieldName>: it could be anything:

JCO.Table jcoTable = jcoTable.getTable(<field name>);

// or JCO.Structure jcoTable = jcoTable.getStructure(<field name>);

// or JCO.Field jcoField = jcoTable.getField(<field name>);

// go ahead with the field: a) get plain value or b) iterate over its rows if it's a table again

}

// close the connection

...

BR, Sergei

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Andy

Please, give your awarding points to this post - it's my second account. I posted the previous one with the wrong account))

Thanks,

Sergei

Former Member
0 Kudos

No problem. Thank you again for your help.

Answers (0)