cancel
Showing results for 
Search instead for 
Did you mean: 

JCO2 server - return table parameters from JAVA to SAP

Former Member
0 Kudos

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')

  }

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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");

Former Member
0 Kudos

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

Former Member
0 Kudos

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