cancel
Showing results for 
Search instead for 
Did you mean: 

JAVA RFC output as Table

Former Member
0 Kudos


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.

Accepted Solutions (0)

Answers (2)

Answers (2)

vijay_kumar49
Active Contributor
0 Kudos

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

former_member191660
Participant
0 Kudos

Hi Vijay, please note that your code is JCo 2.x, wich is not supported by SAP since March 2013

https://service.sap.com/sap/support/notes/549268

former_member191660
Participant
0 Kudos

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.

}