我有一个名为 ZRFC_BOM_005 的 SAP RFC。执行 RFC 函数后,我尝试从返回的表中获取字段的值,但它只显示字段的名称而没有字段的值。但是,函数“printJCoTable(JCoTable jcoTable)”可以与其他 RFC 一起正常工作。我不知道这里有什么问题。
这是我的代码:
执行 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);
使用 printJCoTable 打印表格的字段和表格的值:
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;
}
但事实证明只有字段的名称,但没有字段的值。
PS:我确定返回的字段值与我输入的参数相同,因为我已经通过另一个链接到 SAP 的软件对其进行了检查。
有可能是超时问题吗?因为当我执行这个 RFC 时,运行大约需要 10 分钟。
那我该如何解决呢?