Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Downloading dynamic internal table to excel

Hi All,

I have posted thread regarding this problem earlier and i got following code as solution to download field-symbol data

DATA: i_itab type standard table of mara.

FIELD-SYMBOLS : <fs> TYPE STANDARD TABLE .

ASSIGN i_itab to <fs>.

select * from mara into table i_itab up to 100 rows.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'C:\testfile.xls'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

data_tab = <fs>

This code is working fine , when we define statement:

DATA: i_itab type standard table of mara

But, i am defining internal table dynamically and my data resides in table <FS> .

Can anyone please tell how to define internal table i_itab like table <FS>. ?

Tags:
replied

Hi,

check this sample code,

DATA:
  o_ref TYPE REF TO data.
FIELD-SYMBOLS:
  <lt_table> TYPE STANDARD TABLE,
  <fs>       TYPE ANY,
  <field>    TYPE ANY,
  <field1>   TYPE ANY.
PARAMETERS:
  p_tab       TYPE tabname.       " Table name (eg: MARA)
*  p_field(20) TYPE c.                 " Field name (eg: MATNR)
 
START-OF-SELECTION.
  CREATE DATA o_ref TYPE TABLE OF (p_tab).
 
  ASSIGN p_field TO <field1>.
  ASSIGN o_ref->* TO <lt_table>.
 
  SELECT *
    FROM (p_tab) 
    INTO TABLE <lt_table> upto 100 rows.
IF sy-subrc eq 0.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename = 'C:\testfile.xls'
    WRITE_FIELD_SEPARATOR = 'X'
  TABLES
    data_tab = <lt_table>.
endif.

Regards

Adil

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question