java - 如何从 JCoTable 对象中读取特定值
问题描述
我通过RFC_GET_TABLE_ENTRIES
. 它工作得很好,并列出了表格的所有行。
我现在的问题是我不知道如何得到一个值。通常我会喜欢代码[x][y]
,但这不起作用,因为它不是一个普通的二维数组表,而是一个JCOtable
,我不知道它是如何工作的。
代码有点长,但这是调用本身。
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();
这是控制台输出
System.out.println("RFC_GET_TABLE_ENTRIES");
for (int i = 0; i < 30; i++) {
codes.setRow(i);
System.out.println(codes.getString("WA"));
}
解决方案
getString
实际上也接受索引。如果要根据 x 和 y 检索值,可以执行以下操作
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
它的工作方式与数组类似codes[x][y]
,但这并不常用。
在其他情况下,您可能希望使用 遍历行中的每个单个值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
}
推荐阅读
- jquery - 我需要使用 ajax 更新网格中更改的行
- amazon-web-services - 向 Amazon SQS 标准队列发送带有计时器的消息不起作用
- angularjs - 指令中的重置值
- mql5 - 将整数转换为字符串 MQL5 时省略零
- google-ads-api - 如何获取 Google 广告再营销代码的 Feed ID?
- c# - 如何使用 TFS 客户端库获取 PullRequest 的 Web URL?
- c# - 带有子查询、计数、最大值、总和的 Linq 查询,左连接扩展
- spring - 如何在 Springboot 应用程序中删除 Favicon?
- linux - 与标志 MAP_HUGETLB 相比,hugetlbfs 的优势
- python - 使用 tf.train.Saver() 保存和恢复训练模型时损失值跳跃