Skip to Content
avatar image
Former Member

JAVA RFC output as Table


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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Sep 25, 2014 at 05:39 AM

    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.

    }

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 26, 2014 at 04:21 AM

    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

    Add comment
    10|10000 characters needed characters exceeded