on 06-02-2009 7:55 PM
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
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.