I have a SAP RFC named ZRFC_BOM_005. After I exec the RFC function, I try to get field's value from the returned table, but it only shows field's name but no field's value. However, the function "printJCoTable(JCoTable jcoTable)" works fine with other RFC. I don't know what's wrong with it here.
This is my code:
Execute SAP RFC:
JCoFunction function = destination.getRepository().getFunction("ZRFC_BOM_005");
JCoParameterList input = function.getImportParameterList();
input.setValue("DATE_FROM", datefrom);
input.setValue("DATE_TO", dateto);
input.setValue("I_CAPID", i_capid);
input.setValue("I_MEHRS", i_mehrs);
input.setValue("I_MTNRV", i_mtnrv);
input.setValue("I_STLAN", i_stlan);
input.setValue("I_WERKS", i_werks);
if (function == null)
throw new RuntimeException("ZRFC_BOM_005 not found in SAP.");
try {
function.execute(destination);
} catch (AbapException e) {
System.out.println(e.toString());
}
JCoTable table = function.getTableParameterList().getTable("T_BOMITEM");
printJCoTable(table);
Use printJCoTable to print table's field and table's value:
public static List<List<String>> printJCoTable(JCoTable jcoTable) {
List<List<String>> listData = new ArrayList<List<String>>();
// header
// JCoRecordMeataData is the meta data of either a structure or a table.
// Each element describes a field of the structure or table.
JCoRecordMetaData tableMeta = jcoTable.getRecordMetaData();
for (int i = 0; i < tableMeta.getFieldCount(); i++) {
System.out.print(String.format("%s\t\t", tableMeta.getName(i)));
}
System.out.println(); // new line
// line items
for (int i = 0; i < jcoTable.getNumRows(); i++) {
// Sets the row pointer to the specified position(beginning from zero)
jcoTable.setRow(i);
// Each line is of type JCoStructure
List list = new ArrayList<>();
for (JCoField fld : jcoTable) {
list.add(fld.getValue());
System.out.print(String.format("%s\t", fld.getValue()));
}
listData.add(list);
System.out.println();
}
return listData;
}
But it turns out only field's name but no field's value.
PS:I'm sure that there are returned field's value exist with the same params i put, because i have checked it by another software which is link to SAP.
is it possible to be Timeout problem ? because when I exec this RFC, it takes about 10 mins to run.
Then how can I solve this?