Skip to Content
0
Former Member
Jan 18, 2006 at 04:01 PM

Accessing fields with unknown names

70 Views

Okay, I'm finding this a bit tricker than I originally thought it would be.

I've got an internal table going by the name of xinttab, and a string zhtml. I also have the following:

data: zrows type i,
      zcols type i,
      zctyp type c.

field-symbols: <fs_xinttab> type any.

zrows = lines( xinttab ).
describe field xinttab type zctyp components zcols.

clear zhtml.
move '<table>' to zhtml.
do zrows times.
  read table xinttab index sy-index assigning <fs_xinttab>.
  concatenate zhtml '<tr>' into zhtml.
  do zcols times.
    concatenate zhtml '<td>' into zhtml.
    concatenate zhtml <fs_xinttab>-somefield into zhtml.
    concatenate zhtml '</td>' into zhtml.
  enddo.
  concatenate zhtml '</tr>' into zhtml.
enddo.
concatenate zhtml '</table>' into zhtml.

Now, obviously that "<fs_xinttab>-somefield" isn't going to do a right lot. So what I need is either a way of determining the name of the field at position <i>x</i> in a structure, or a way of referring to a field by its structure index (as opposed to row index).

Any help on this would be massively appreciated as I'm hoping to get this finished in the next hour or so... :-S

If I'm going about that completely the wrong way please feel free to say so, I don't mind starting again!