Application Development and Automation 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: 
Read only

RTTS - dynamic table output

Former Member
0 Likes
599

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

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
546

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®

3 REPLIES 3
Read only

former_member194669
Active Contributor
0 Likes
547

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®

Read only

Former Member
0 Likes
546

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.

Read only

0 Likes
546

Thanks a lot to both of you.