Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

JCo3 - How to parse the metadata of the structure of a function?

Hi,

when converting our JCo2 based interface to JCo3 I encounter this problem: In JCo2 I could easily parse structures of ImportParameterList of TableParameterList by fields() and getString():

Pseudocode:

  input= function.getImportParameterList()

  kopf = input.getStructure("KOPF")

  fi   = kopf.fields()

  while fi.hasMoreElements()

    fld = fi.nextField()

    System.out.println(fld.getName()+" "+fld.getString())

  wend

 
  tables = function.getTableParameterList()

  pos    = tables.getTable("POSITION")

  for pp=0 to pos.getNumRows()-1

      pos.setRow(pp)

      fi = pos.fields()

      jcoServer.printlog("Position:"+pp)

      while fi.hasMoreElements()

            fld = fi.nextField()

            System.out.println(fld.getName()+" "+fld.getString())

      wend

   next pp

My attempts, to do similar with JCo3 showed the problem:

Pseudo code 1:

  input= function.getImportParameterList()

  kopf = input.getStructure("KOPF")

  fields = kopf.getMetaData().getFieldCount()

  for feld=0 to fields-1

      System.out.println(kopf.getMetaData().getName(feld)+" "+kopf.getMetaData().getString(feld))

      // results in: No match for method com.sap.conn.jco.rt.DefaultRecordMetaData.getString(java.lang.Integer)

  next

Pseudo code 2:

  tables = function.getTableParameterList()

  pos    = tables.getTable("POSITION")

  rows = pos.getNumRows()

  for row=0 to rows-1

      pos.setRow(row)

      row=new java.lang.Integer(row)

      System.out.println(pos.getMetaData().getName(row)+" "+pos.getMetaData().getString(row))

      // results in: java.lang.IndexOutOfBoundsException: Index [32] out of bounds.The metadata 'ZJMM_KMK_GM_POS' contains 26 fields

  next

(I know it looks like I run out of bounds, but I attempt to take care of them by looping only for existing rows rows = pos.getNumRows())

Maybe some expert can assist here?

Many thanks for all help

Stephan

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question