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

Former Member
0 Kudos

hi,

ihave written the following code to download the data to excel.

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(eg:data_30102008)

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

3 REPLIES 3

Former Member
0 Kudos

Hi,

Try like this....



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

concatenate v_pass_path '_' sy-datum  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 = 'ASC'
TABLES
data_tab = GT_FINAL

Hope it will helps

Former Member
0 Kudos

Hi Hema,

Please try the following code.



DATA:BEGIN OF IT_ZSTUDENT OCCURS 0.
     INCLUDE STRUCTURE ZSTUDENT.
DATA:END OF IT_ZSTUDENT.
DATA:FNAME type string.

concatenate 'C:\' 'DATA_' sy-datum '.xls' into fname.

SELECT * from zstudent into table it_zstudent up to 5 rows.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME                        = FNAME
   FILETYPE                        = 'ASC'
   WRITE_FIELD_SEPARATOR           = 'X'
  TABLES
    DATA_TAB                        = it_zstudent.

IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Thanks,

N.K.C

Former Member
0 Kudos

Hi,

This code may help u...


  DATA:     w_file_name TYPE string,
            w_full_path TYPE string,
            full_path TYPE string,
            action TYPE i.

  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      window_title         = 'ABCD'
      initial_directory    = 'c:\Documents and Settings\2q\Desktop'
      prompt_on_overwrite  = 'X'
      default_extension    = 'XLS'
      default_file_name    = 'ABCD'
    CHANGING
      filename             = w_file_name
      path                 = w_file_path
      fullpath             = full_path
      user_action          = action
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      not_supported_by_gui = 3
      OTHERS               = 4.

  IF action EQ 0.
    CALL METHOD cl_gui_frontend_services=>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.

Edited by: Sukriti Saha on Oct 30, 2008 4:22 PM