1

I successfully got the Table entries from a SAP system via RFC_GET_TABLE_ENTRIES. It works all fine and lists me all the rows of the table.

My problem right now is that I have no idea how to get a single value out. Usually I would go like codes [x][y] but that doesn't work because it is not a normal two-dimensional-array table but a JCOtable and I have no idea how that works.

The code is a little longer but this is the call itself.

JCoDestination destination = JCoDestinationManager.getDestination("mySAPSystem");
JCoFunction function = destination.getRepository().getFunction("RFC_GET_TABLE_ENTRIES");



if (function==null)
    throw new RuntimeException("Function not found in SAP.");

function.getImportParameterList().setValue( "MAX_ENTRIES", 30);
function.getImportParameterList().setValue( "TABLE_NAME", "ZTEST_TABLE ");
JCoTable codes = function.getTableParameterList().getTable("ENTRIES");
codes.appendRow();

and this is the console output

System.out.println("RFC_GET_TABLE_ENTRIES");

for (int i = 0; i < 30; i++) {
    codes.setRow(i);
    System.out.println(codes.getString("WA"));
}
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
IVnoobSuck
  • 75
  • 10

1 Answers1

0

getString actually accepts indexes as well. If you want to retrieve values according to x and y you can do the following

codes.setRow(y);
String value = codes.getString(x); // It can also be getFloat, getInt, etc. depending on the data type,
                                   // or getValue, which gives you an Object

It works similarly to codes[x][y] as if it's an array, but this is not commonly used.

In other cases, you may want to iterate through each single value in the row with JCoRecordFieldIterator.

JCoRecordFieldIterator itr = codes. getRecordFieldIterator();
while(itr.hasNextField()){
    JCoRecordField field = itr.nextRecordField();
    String value = field.getValue(); // Or getString, getFloat, etc.
    // Whatever you want to do with the value
}
PIG208
  • 2,060
  • 2
  • 10
  • 25