Skip to Content
0
Former Member
Mar 04, 2014 at 01:16 PM

Field names of internal table

3894 Views


Hello,

I am trying to retrieve the field names of internal table itab using FM 'GET_COMPONENT_LIST'

Executing the function module in se37 for my program and itab, I get the fieldnames in COMPONENTS table.

But when using it in report ztestv, COMPONENTS is empty.

I tried to search the forum and carried out the steps as mentioned, but didn't find any solution.

Following is my code:

-------------------------------------------------------------------------------------------------------------------------------------------------

REPORT ZTESTV .

data: begin of itab occurs 0,

NAME1 type string,

age type i,

amt type i,

end of itab.

DATA : work_area LIKE LINE OF itab.

data: wa_csv_out type table of string.

itab-name1 = 'AAAA'.

itab-age = 20.

itab-amt = 120.

append itab.

itab-name1 = 'BBBB'.

itab-age = 40.

itab-amt = 150.

append itab.

itab-name1 = 'CCCC'.

itab-age = 25.

itab-amt = 400.

append itab.

 

DATA: lt_comp TYPE table of RSTRUCINFO,

ls_comp TYPE RSTRUCINFO.

CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

PROGRAM = sy-repid

FIELDNAME = itab

TABLES

COMPONENTS = lt_comp.

LOOP AT lt_comp into ls_comp.

append ls_comp-compname to wa_csv_out.

ENDLOOP.

-------------------------------------------------------------------------------------------------------------------------------------------------

Please help.