Skip to Content
avatar image
Former Member

JCO2 server - return table parameters from JAVA to SAP

my SAPsystem connects to an java-service .. thats works.

But I don't know, how I can return table parameters from JAVA to SAP.

ABAP:
call function 'STFC_CONNECTION'
  destination 'JCO_RFC'
  exporting
    requtext = requtext
  importing
    echotext = echotext
    resptext = resptext
  tables
    rfctest  = rfctest.

JAVA: Example5.java - extract from the downloaded JCo2 ZIP demo file ...

 if (function.getName().equals("STFC_CONNECTION")) {
         
        output.setValue(input.getString("REQUTEXT"),"ECHOTEXT");
        output.setValue("This is a response from Example5.java","RESPTEXT");
        
        How to append data in the rfctest table...
        tables.setValue(???,'RFCTEST')

  }

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Apr 03, 2009 at 05:22 AM

    Hi Aru,

    You can take help of bellow code to append a row in JCO table.

    			Table table = function.getTableParameterList().getTable("<Table Name>");
    			table.appendRow();
    			table.setValue(<value>,"field1 Name");
    			table.setValue(<value>,"field2 Name");
    

    to append one more row in same table you will have to repeat bellow code as many times you want

    
    			table.appendRow();
    			table.setValue(<value>,"field1 Name");
    			table.setValue(<value>,"field2 Name");
    

    Ninad

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Ninad,

      Above source code, it's work for JCo Client but I'm not able to understand why it doesn't work for JCO server:

      JAVA: Example5.java - extract from the downloaded JCo2 ZIP demo file ...
      if (function.getName().equals("STFC_CONNECTION")) {
              output.setValue(input.getString("REQUTEXT"),"ECHOTEXT");
              output.setValue("This is a response from Example5.java","RESPTEXT");
              
              //Aru added
              JCO.Table table = function.getTableParameterList().getTable("RFCTEST");
              
            }
      

      SAPsystem return runtime errors: "java.lang.NullPointerException"

      It's seems got that table is null?

      Regards,

      Aru

  • avatar image
    Former Member
    Apr 10, 2009 at 04:29 AM

    Update... It's work...

    We do not have the definition of RFCTEST table in the Add function 'STFC_CONNECTION' as below:

    fmeta.addInfo("RFCTEST", JCO.TYPE_TABLE, 144, 0, 0, 0, "RFCTEST");

    Add comment
    10|10000 characters needed characters exceeded