Hi,
here is a sample
field-symbols: <ls_comp> type any.
loop at gt_alv into ls_alv. "table with corresponding structure
clear: lv_astring. "type string
do.
assign component sy-index of structure ls_alv to <ls_comp>.
if sy-subrc = 0.
lv_astring = <ls_comp>.
transfer lv_astring to p_file.
else.
exit.
endif.
enddo.
endloop.