2008 May 05 1:58 PM
Hi Experts,
i have to download 4 internal tables, each with different structures, to the presentation server using 'gui_download', based on which radio-button is selected in the selection screen. I am hoping to use a single 'form' and 4 'perform' calls. how can I dynamically change the tables in the 'gui_download' function modules.
plz help.....................
2008 May 05 2:17 PM
The code below worked for me.
report test.
data:
BEGIN of itab1 occurs 0,
matnr type mara-matnr,
end of itab1,
BEGIN of itab2 occurs 0,
vbak type vbak-vbeln,
end of itab2.
select vbeln from vbak into table itab2 up to 10 rows.
select matnr from mara into table itab1 up to 10 rows.
perform download using itab1[].
perform download using itab2[].
form download using itab type standard table.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\ITAB.TXT'
APPEND = 'X'
tables
data_tab = itab.
endform.
Hi Experts,
i have to download 4 internal tables, each with different structures, to the presentation server using 'gui_download', based on which radio-button is selected in the selection screen. I am hoping to use a single 'form' and 4 'perform' calls. how can I dynamically change the tables in the 'gui_download' function modules.
plz help.....................
2008 May 05 2:05 PM
Hi ,
Build the field catalog dynamically based on the internal table structure based on the radio button selected.Use the dynamic internal table generated from the filedcatalog and use in GUI_DOWNLOAD.
See the below code:
&----
*& Report ZRAJESH02
*&
&----
*&
*&
&----
REPORT zrajesh02.
Dynamic internal table
TYPE-POOLS: slis.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>.
DATA: alv_fldcat TYPE slis_t_fieldcat_alv,
it_fldcat TYPE lvc_t_fcat.
DATA: lv_monate TYPE f,
lv_months TYPE i,
lv_date TYPE sy-datum,
p_check1 type n value '1'.
lv_date = sy-datum + 360.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_check TYPE c.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = lv_date
i_datum_von = sy-datum
i_kz_incl_bis = ' '
IMPORTING
e_monate = lv_monate.
lv_months = lv_monate.
PERFORM f_fcat USING 'AUFNR' 'CHAR' '12'.
PERFORM f_fcat USING 'POSNR' 'CHAR' '06'.
while p_check1 LE p_check.
PERFORM f_fcat USING p_check1 'CHAR' '1'.
p_check1 = p_check1 + 1.
endwhile.
PERFORM build_dyn_itab.
LOOP AT <dyn_table> INTO <dyn_wa>.
WRITE:/ <dyn_wa>.
ENDLOOP.
*************************************************************************
FORM f_fcat USING fieldname dattyp length.
DATA:wa_it_fldcat TYPE lvc_s_fcat.
CLEAR wa_it_fldcat.
wa_it_fldcat-fieldname = fieldname.
wa_it_fldcat-datatype = dattyp.
wa_it_fldcat-intlen = length.
APPEND wa_it_fldcat TO it_fldcat .
ENDFORM. "f_fcat
&----
*& Form build_dyn_itab
&----
text
----
FORM build_dyn_itab.
DATA: new_table TYPE REF TO data,
new_line TYPE REF TO data.
wa_it_fldcat TYPE lvc_s_fcat.
CLEAR wa_it_fldcat.
wa_it_fldcat-fieldname = 'AUFNR'.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 12.
APPEND wa_it_fldcat TO it_fldcat .
CLEAR wa_it_fldcat.
wa_it_fldcat-fieldname = 'POSNR'.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 6.
APPEND wa_it_fldcat TO it_fldcat .
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
CREATE DATA new_line LIKE LINE OF <dyn_table>.
ASSIGN new_line->* TO <dyn_wa>.
ENDFORM. "build_dyn_itab
Thanks,
Rajesh.
2008 May 05 2:14 PM
Hello,
Try this:
DATA: itab1 TYPE ty_type1,
itab2 TYPE ty_type2,
itab3 TYPE ty_type3.
PERFORM test USING: 'ITAB1', 'ITAB2', 'ITAB3'.
FORM test USING p_itabname TYPE string.
FIELD-SYMBOLS: <fs_itab> TYPE TABLE,
<fs_wa> TYPE ANY.
ASSIGN (p_itabname) TO <fs_itab>.
IF <fs_itab> IS ASSIGNED.
LOOP AT <fs_itab> ASSIGNING <fs_wa>.
<TREATMENTS>.
ENDLOOP.
ENDIF.
ENDFORM.
2008 May 05 2:17 PM
The code below worked for me.
report test.
data:
BEGIN of itab1 occurs 0,
matnr type mara-matnr,
end of itab1,
BEGIN of itab2 occurs 0,
vbak type vbak-vbeln,
end of itab2.
select vbeln from vbak into table itab2 up to 10 rows.
select matnr from mara into table itab1 up to 10 rows.
perform download using itab1[].
perform download using itab2[].
form download using itab type standard table.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\ITAB.TXT'
APPEND = 'X'
tables
data_tab = itab.
endform.
2008 May 05 2:35 PM
hi do like this:
case 'X'.
when radio1 .
clear: lt_tab2[], lt_tab3[], lt_tab4[].
perform download_gui tables lt_tab1 lt_tab2 lt_tab3 lt_tab4.
when radio2.
clear: lt_tab1[], lt_tab3[], lt_tab4[].
perform download_gui tables lt_tab1 lt_tab2 lt_tab3 lt_tab4.
when radio3.
clear: lt_tab1[], lt_tab2[], lt_tab4[].
perform download_gui tables lt_tab1 lt_tab2 lt_tab3 lt_tab4.
when radio4.
clear: lt_tab1[], lt_tab2[], lt_tab3[].
perform download_gui tables lt_tab1 lt_tab2 lt_tab3 lt_tab4.
endcase.
form gui tables lt_tab1 lt_tab2 lt_tab3 lt_tab4.
if it_tab1[] in not initial.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = ''
tables
data_tab = it_tab1[]
endif.
if it_tab2[] in not initial.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = ''
tables
data_tab = it_tab2[]
endif.
if it_tab3[] in not initial.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = ''
tables
data_tab = it_tab3[]
endif.
if it_tab4[] in not initial.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = ''
tables
data_tab = it_tab4[]
endif.
endform.
reward if useful.
endform.