‎2008 Jul 30 7:30 AM
Hi,
How to know number of columns in an internal table at run-time.
‎2008 Jul 30 7:32 AM
just do this.
DATA : BEGIN OF it_mara OCCURS 0,
matnr LIKE mara-matnr,
ersda LIKE mara-ersda,
END OF it_mara.
DATA : p(5) TYPE c.
FIELD-SYMBOLS: <fs_record> TYPE ANY.
FIELD-SYMBOLS: <fs_comp> TYPE ANY.
ASSIGN it_mara TO <fs_record>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_record> TO <fs_comp>.
IF sy-subrc EQ 0.
p = p + 1.
ELSE.
EXIT.
ENDIF.
ENDDO.
WRITE : / p.Regards,
Anversha
‎2008 Jul 30 7:31 AM
Hi
To find out the attributes of an internal table at runtime that were not available statically, use the statement:
DESCRIBE TABLE <itab> LINES <l> OCCURS <n> KIND <k>.
Regards
Pavan
‎2008 Jul 30 7:31 AM
‎2008 Jul 30 7:32 AM
just do this.
DATA : BEGIN OF it_mara OCCURS 0,
matnr LIKE mara-matnr,
ersda LIKE mara-ersda,
END OF it_mara.
DATA : p(5) TYPE c.
FIELD-SYMBOLS: <fs_record> TYPE ANY.
FIELD-SYMBOLS: <fs_comp> TYPE ANY.
ASSIGN it_mara TO <fs_record>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_record> TO <fs_comp>.
IF sy-subrc EQ 0.
p = p + 1.
ELSE.
EXIT.
ENDIF.
ENDDO.
WRITE : / p.Regards,
Anversha
‎2008 Jul 30 7:33 AM
Hi Arun,
Use DESCRIBE statement.
Please check this link
[DESCRIDE statement|http://www.sapdb.org/7.4/htmhelp/f6/c3e002e200884292a3e629b6c41b96/content.htm]
Best regards,
raam
‎2008 Jul 30 7:33 AM
Hi,
you can use the Describe lines itab into a variable.
if you are in a loop and find the index of the itab you can use the sy-tabix system field.
‎2008 Jul 30 7:34 AM
‎2008 Jul 30 8:48 AM