title: Getting error attempting to Iterate over a JCoTable using java.util.iterator
body: <p>Am trying to implement some Java patterns (Facade, and Iterator) against JCo objects.  </p>
  
  <p>Here, I'm trying to create an Iterator over the JCoTable much like I would any collection in Java.  Below is my class snippet. In MyClass I have an inner class that performs the iteration.</p>
  
  <p>I'm using the table.getStructure(...) methods, but am missing something.  I've seen some snippets where they're explicitly creating a structure using metadata, but honestly, the code is not present in those examples, and I struggle a little there, worrying that I'm trading one complexity for another.</p>
  
  <p>My goal is to simplify SAP Bapi calls and table handling for other Java programmers.  This is a refactoring exercise.  My return variables are incompatible in the Iterator.</p>
  
  <p>Thank you in advance.  </p>
  
  <p>My class:</p>
  
  <pre><code>class MyClass 
  ...
  protected JCoTable table;
  ...
  
  private class JCoTableIterator implements Iterator&lt;JCoRecord&gt; {
  
      public boolean hasNext() {
          return table.getRow() &lt; table.getNumRows();
      }
      @Override
      public JCoRecord next() {
          return table.getStructure(table.getRow() + 1);
      }
      @Override
      public void remove() {
          table.deleteRow();
      }
  }
  </code></pre>
  
  <p>My implementation:</p>
  
  <pre><code>Iterator&lt;JCoRecord&gt; it = table.iterator();
  while(it.hasNext()) {
      JCoRecord record = it.next(); &lt;&lt;&lt;&lt;&lt; *Exception
      logger.info(record.getString("WERKS"));
      ... other field procesing ... 
  }  
  </code></pre>
  
  <p>But on the JCoRecord record = it.next() line I get the following error.</p>
  
  <pre><code>com.sap.conn.jco.ConversionException: (122) JCO_ERROR_CONVERSION: Cannot convert field VBELN of type CHAR to StructureRecord
      at com.sap.conn.jco.rt.AbstractRecord.createConversionException(AbstractRecord.java:415)
      at com.sap.conn.jco.rt.AbstractRecord.createConversionException(AbstractRecord.java:410)
      at com.sap.conn.jco.rt.AbstractRecord.getStructure(AbstractRecord.java:2472)    
  </code></pre>