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: 

download data to file

Former Member
0 Kudos

hi,

all the data i need to dispaly in the output is in final internal table gt_final.

whereas the problem i need to download this data to excelsheet.

please let me know what are the varibles i need to pass to the FM GUI_DOWNLOAD

where i need to write this FM.

Please help me

7 REPLIES 7

Former Member
0 Kudos

Hi,

Check the function module documentation in SE37, it has a example code.

Thanks & Regards,

Navneeth K.

Former Member
0 Kudos

Hi,

Pass values like this...


    CALL METHOD gui_download
      EXPORTING
        filename                = w_file_name
        filetype                = 'DAT'
      CHANGING
        data_tab                = <tab>
      EXCEPTIONS
        file_write_error        = 1
        no_batch                = 2
        gui_refuse_filetransfer = 3
        invalid_type            = 4
        no_authority            = 5
        unknown_error           = 6
        header_not_allowed      = 7
        separator_not_allowed   = 8
        filesize_not_allowed    = 9
        header_too_long         = 10
        dp_error_create         = 11
        dp_error_send           = 12
        dp_error_write          = 13
        unknown_dp_error        = 14
        access_denied           = 15
        dp_out_of_memory        = 16
        disk_full               = 17
        dp_timeout              = 18
        file_not_found          = 19
        dataprovider_exception  = 20
        control_flush_error     = 21
        not_supported_by_gui    = 22
        error_no_gui            = 23
        OTHERS                  = 24.

Regards

Debarshi

GauthamV
Active Contributor
0 Kudos

hi,

you can just pass file name where you want to stor and your final table name.


DATA : file_name TYPE string.
data:file(45) TYPE c .

CONCATENATE 'c:\' 'Data' '_' sy-datum '.txt' INTO file.

  file_name = file.

 CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
*   BIN_FILESIZE                    =
      filename                        = file_name
      filetype                        = 'ASC'
      append                          = 'X'
    TABLES
      data_tab                        = it_final
            .

Former Member
0 Kudos

hi frnd,

call fm gui_download ....pass your internal table name and and the file path where you want to download file as excel file .

Thanks and regards .

Priyank dixit

Former Member
0 Kudos

Hi hema,

file_name = file.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = file_name

filetype = 'ASC'

append = 'X'

TABLES

data_tab = it_final

Use this code to download the file.

Regards,

PK

former_member598013
Active Contributor
0 Kudos

Hi Hema,

You can use the below sample Program for your reference.


*&---------------------------------------------------------------------*
*& Report  ZCC_EXCEL_DOWNLOAD
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZCC_EXCEL_DOWNLOAD.
TYPE-POOLS:
            sydes.

data : Begin of t_header occurs 0,
       name(30) type c,
       end of t_header.

data : Begin of itab occurs 0,
       fld1 type char10,
       fld2 type char10,
       fld3 type char10,
       end   of itab.

 DATA: v_pass_path TYPE string value 'c:\excel\test.xlsx'..

 DATA: sy_repid LIKE sy-repid,
        td       TYPE sydes_desc.
  sy_repid = sy-repid.




append itab.
itab-fld1 = 'Hi'.
itab-fld2 = '100.00'.
itab-fld3 = 'welcome'.
append itab.
append itab.
append itab.
append itab.
append itab.

t_header-name = 'Field1'.
append t_header.
t_header-name = 'Field2'.
append t_header.
t_header-name = 'Field3'.
append t_header.

 DESCRIBE FIELD itab INTO td.

  CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
    EXPORTING
      default_extension     = 'XLS'
    IMPORTING
      fullpath              = v_pass_path.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                        = v_pass_path
      filetype                        = 'DBF'
    TABLES
      data_tab                        = itab
      FIELDNAMES                      = t_header
      .

Thanks,

Chidanand

0 Kudos

hi,

ihave written the following code to download.

the download was successfull but i am getting extra columns with zeros

and i need to set default file name as data_sy-datum.

the filename i am not getting which i have set.

please check the below code and sugest me

s_name = sy-datum.

DATA: v_pass_path TYPE string value 'C:\Documents and Settings\latha\Desktop\'.

concatenate v_pass_path s_name into v_file1.

CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'

EXPORTING

default_extension = 'XLS'

IMPORTING

fullpath = v_file1.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = v_file1

filetype = 'DBF'

TABLES

data_tab = GT_FINAL

  • FIELDNAMES = t_header

.