The data from SAP is returned as a JCo.Table. However, we don't want to display ALL the columns in the VIEW. So, what we have done is, we have created a file called display.xml which has the JCO.Table columns to be displayed. The display.xml is converted to a List and each field is verified if it is present in the display list(see the code below) which is redundant from second row onwards.
final Table outputTable = jcoFunction.getTableParameterList().
getTable("OUTPUT_TABLE");
final int numRows = outputTable.getNumRows();
for (int i = 0; i < numRows; i++) {
final FieldIterator fields = outputTable.fields();
while (fields.hasNextFields()) {
final JCO.Field recordField = fields.nextField();
final String sapFieldName = recordField.getName();
final DisplayFieldDto key = new DisplayFieldDto(sapFieldName);
if (displayFields.contains(key)) {
System.out.println("recordField.getName() = "
+ recordField.getName());
final String sapFieldName = (String)recordField.getValue();
} else {
// ignore the field.
}
}
}
What is the better way to filter the fields in JCo? Can I iterate column wise? Thank you :)