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

FM to write data to flat file

Former Member
0 Likes
544

Hi,

I am looking for a FM to write data from a table to a tab delimited file. Would GUI_DOWNLOAD work?

Thanks

Will

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
509

Check out this sample code

* This method of file download with check uses the latest techniques 
* and achieves a very neat solution
  DATA: ld_filename TYPE string,
        ld_path TYPE string,
        ld_fullpath TYPE string,
        ld_result TYPE i.
 
* Display save dialog window
  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
*      window_title      = ' '
      DEFAULT_EXTENSION = 'XLS'
      default_file_name = 'accountsdata'
      INITIAL_DIRECTORY = 'c:temp'
    CHANGING
      filename          = ld_filename
      path              = ld_path
      fullpath          = ld_fullpath
      user_action       = ld_result.
 
* Check user did not cancel request
  CHECK ld_result EQ '0'.
 
  CALL FUNCTION 'GUI_DOWNLOAD'
   EXPORTING
        filename         = ld_fullpath
        filetype         = 'ASC'
*       APPEND           = 'X'
        write_field_separator = 'X'
*       CONFIRM_OVERWRITE = 'X'
   TABLES
        data_tab         = it_datatab[]     "need to declare and populate
   EXCEPTIONS
        file_open_error  = 1
        file_write_error = 2
        OTHERS           = 3.

Hi,

I am looking for a FM to write data from a table to a tab delimited file. Would GUI_DOWNLOAD work?

Thanks

Will

3 REPLIES 3
Read only

Former Member
0 Likes
509

Yes it works ...

Read only

Former Member
0 Likes
509

Hi,

Try passing the parameter WRITE_FIELD_SEPARATOR = 'X' when calling the GUI_DOWNLOAD..I believe it will create tab delimited file..

Thanks,

Naren

Read only

Former Member
0 Likes
510

Check out this sample code

* This method of file download with check uses the latest techniques 
* and achieves a very neat solution
  DATA: ld_filename TYPE string,
        ld_path TYPE string,
        ld_fullpath TYPE string,
        ld_result TYPE i.
 
* Display save dialog window
  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
*      window_title      = ' '
      DEFAULT_EXTENSION = 'XLS'
      default_file_name = 'accountsdata'
      INITIAL_DIRECTORY = 'c:temp'
    CHANGING
      filename          = ld_filename
      path              = ld_path
      fullpath          = ld_fullpath
      user_action       = ld_result.
 
* Check user did not cancel request
  CHECK ld_result EQ '0'.
 
  CALL FUNCTION 'GUI_DOWNLOAD'
   EXPORTING
        filename         = ld_fullpath
        filetype         = 'ASC'
*       APPEND           = 'X'
        write_field_separator = 'X'
*       CONFIRM_OVERWRITE = 'X'
   TABLES
        data_tab         = it_datatab[]     "need to declare and populate
   EXCEPTIONS
        file_open_error  = 1
        file_write_error = 2
        OTHERS           = 3.