on 09-12-2014 1:39 PM
Hi All ,
I am trying to write a java code to read data from SAP using RFC_READ_TABLE call.
For RFC_READ_TABLE , import parameter is "QUERY_TABLE" that I have given it in my java code as
function.getImportParameterList().setValue("QUERY_TABLE", "Table_name");
and RFC returns table.
I don't know how to read the table output in java.
How can I read this table and iterate over the all the data in java.
It would be very helpful , if anyone can help me on this.
Hello Supriya,
Well as far as calling a RFC from java is concerned....below is code that worked fine for me.
JCO.Client connClient = null;
IRepository mRepository;
connClient = JCO.createClient("<SAP Client>","<UserId>","<Password>","EN","<Application server host name>","<system number>");
try {
connClient.connect();
} catch (Exception ex)
{
ex.printStackTrace();
System.exit(1);
}
mRepository = new JCO.Repository("Hell", connClient);
JCO.Function strHELLO = mRepository.getFunctionTemplate("ZSAU_FM_ASSIGNMENT").getFunction();
JCO.ParameterList importParam = strHELLO.getImportParameterList();
importParam.setValue(val,"ZMATNR");
try {
connClient.execute(strHELLO);
}catch (JCO.AbapException ex)
{
}
Please look at http://scn.sap.com/thread/3475377 and http://help.sap.com/saphelp_nwpi711/helpdata/en/48/634503d4e9501ae10000000a42189b/content.htm
Regards
Vijay K Kalluri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vijay, please note that your code is JCo 2.x, wich is not supported by SAP since March 2013
Hi Supriya,
I assume you are using JCo3. Please refer to the JCo3 javadoc for full answer (you get the javadocs in the JCo3 download package.)
All in all it should be something like
JcoTable queryTable = function.getImportParameterList().getValue("QUERY_TABLE");
queryTable.addRow();...
then (after executing the function)
JCoTable returnTable = function.getExportParameterList().getValue("RETURN_TABLE");
Iteration can be done using something like
while (currentRow = returnTable.nextRow()
{
//do something with the row.
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.