Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

to read the column names of an internal table

Former Member
0 Kudos

Hi ,

I want to read the column/field names of an internal table into another internal table.

How can this be done?

Kind Regards,

hgarsht Rungta

6 REPLIES 6

former_member404244
Active Contributor
0 Kudos

Hi,

W hat is your requirement ? can you please be speific what you want.

Regards,

Nagaraj

kesavadas_thekkillath
Active Contributor
0 Kudos

Former Member
0 Kudos

Hi,

I want to read the field names of an internal table.

eg.

for itab_mara i want to read its field names as matnr ersda etc.

Regards,

Harshit Rungta

0 Kudos

Hi,

u can read like this

itab_mara-matnr.

itab_matnr-ersda.

loop at itab_matnr.

write 😕 itab_matnr-matnr, itab_matnr-ersda.

or if u want to transfer

move :itab_matnr-matnr to itab1_matnr-matnr.

endloop.

Regards,

Nagaraj

Former Member
0 Kudos

Hi harshit,

Kindly check...

field-symbols: <column> type any.

data: w_name type string.

loop at itab.

do.

assign component sy-index of structure itab to <column>.

if sy-subrc = 0.

// getting the fieldname in w_name

w_name = <column>.

else.

exit.

endif.

enddo.

endloop.

Regards,

Mdi.Deeba

Former Member

Hi ,

you can get the attributes of any internal table into another ..

check the following code ..

DATA : it_mara TYPE STANDARD TABLE OF mara  WITH HEADER LINE.

DATA : it_detail   TYPE abap_compdescr_tab,
           wa_comp TYPE abap_compdescr.

DATA : ref_descr TYPE REF TO cl_abap_structdescr.

ref_descr ?= cl_abap_typedescr=>describe_by_data( it_mara ).
it_detail[] = ref_descr->components .

loop at it_detail into wa_comp.
write:/ wa_comp-name .
endloop.

Regards,

Rajesh Kumar