‎2009 Jun 11 4:32 PM
Hi,
I'd like to output the contents of a dynamic table. I dont know the structure and type of the table. I tried to use RTTS methods but I dont know how to output the data.
Here my example code:
REPORT zsm_rtts_test.
DATA: lt_test TYPE TABLE OF spfli.
FIELD-SYMBOLS: <wa_test> LIKE LINE OF lt_test.
" just for example - flight table
SELECT * FROM spfli INTO TABLE lt_test.
DATA: ref_table TYPE REF TO cl_abap_tabledescr,
ref_struct TYPE REF TO cl_abap_structdescr,
fields_table TYPE abap_compdescr_tab.
FIELD-SYMBOLS: <field> LIKE LINE OF fields_table.
ref_table ?= cl_abap_tabledescr=>describe_by_data( lt_test ).
ref_struct ?= ref_table->get_table_line_type( ).
fields_table[] = ref_struct->components.
LOOP AT lt_test ASSIGNING <wa_test>.
LOOP AT fields_table ASSIGNING <field>.
????
ENDLOOP.
ENDLOOP.
How can I give out the contents of the dynamic table? I dont know what to write in place of the question marks.
Thanks a lot.
Regards
Cunanan80
‎2009 Jun 11 4:41 PM
Hi,
Check this
LOOP AT lt_test ASSIGNING <wa_test>.
LOOP AT fields_table ASSIGNING <field>.
assign component sy-tabix of structure <wa_test> to <fs>.
" Here <fs> contains your dynamic table content
ENDLOOP.
ENDLOOP.
a®
‎2009 Jun 11 4:41 PM
Hi,
Check this
LOOP AT lt_test ASSIGNING <wa_test>.
LOOP AT fields_table ASSIGNING <field>.
assign component sy-tabix of structure <wa_test> to <fs>.
" Here <fs> contains your dynamic table content
ENDLOOP.
ENDLOOP.
a®
‎2009 Jun 11 4:42 PM
Like this -:)
DATA: lt_test TYPE TABLE OF spfli.
FIELD-SYMBOLS: <wa_test> LIKE LINE OF lt_test.
" just for example - flight table
SELECT * FROM spfli INTO TABLE lt_test.
DATA: ref_table TYPE REF TO cl_abap_tabledescr,
ref_struct TYPE REF TO cl_abap_structdescr,
fields_table TYPE abap_compdescr_tab.
FIELD-SYMBOLS: <field> LIKE LINE OF fields_table,
<aux> TYPE ANY.
DATA: w_field TYPE string.
ref_table ?= cl_abap_tabledescr=>describe_by_data( lt_test ).
ref_struct ?= ref_table->get_table_line_type( ).
fields_table[] = ref_struct->components.
LOOP AT lt_test ASSIGNING <wa_test>.
LOOP AT fields_table ASSIGNING <field>.
CONCATENATE '<WA_TEST>' <field>-name INTO w_field
SEPARATED BY '-'.
ASSIGN (w_field) TO <aux>.
WRITE: <aux>.
ENDLOOP.
WRITE:/.
ENDLOOP.
Greetings,
Blag.
‎2009 Jun 11 4:47 PM