JCo | How to iterate column wise

Posted by cedar715 on Stack Overflow See other posts from Stack Overflow or by cedar715
Published on 2010-05-06T10:47:36Z Indexed on 2010/05/06 12:38 UTC
Read the original article Hit count: 318

Filed under:
|
|

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 :)

© Stack Overflow or respective owner

Related posts about jco

Related posts about sap