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: 

Save .txt file at User defined Location

former_member435508
Participant
0 Kudos
763

I transfer SAP ITAB to .txt file with --> SAP_CONVERT_TO_TEX_FORMAT

Now I want this .txt file to store at user defined Path (Location).

I used GUI_DOWNLOAD - And it's saved at Desktop. Which is as Required.

But For User Defined Path - when I try CALL METHOD lo_gui->directory_browse - It's not working.

3 REPLIES 3

Former Member
0 Kudos
273

Try this


parameters: p_path type localfile. 
data: path_str type string.

at selection-screen on value-request for p_path.
 
 
  call method cl_gui_frontend_services=>directory_browse
      exporting
         window_title    = 'Select Directory'
      changing
         selected_folder = path_str
      exceptions
         cntl_error = 1.
 
  call method cl_gui_cfw=>flush
       exceptions
          cntl_system_error = 1
          cntl_error        = 2.
 
  p_path =  path_str.

Former Member
0 Kudos
273

Hi priya,

To downlad the data which is in the internal table to the user defined location.

First use the method


CALL METHOD cl_gui_frontend_services=>directory_browse

then ..

for saving the file in the location call the method


 CALL METHOD cl_gui_frontend_services=>file_save_dialog

For example


CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      default_extension    = 'txt'
      file_filter          = 'Text Files(*.TXT)'           "for text files
      initial_directory    = 'C:\'
*      prompt_on_overwrite  = 'X'
    CHANGING
      filename             = l_filename                    "File Names
      path                 = l_path                             " Path of the file
      fullpath             = l_fullpath.                       " Full path including the file name

then use the GUI_DOWNLOAD FM to transfer the data in the itab to the file which you are saving in the presentation server.

Hope it helps.

Regards,

Phani

former_member536879
Active Contributor
0 Kudos
273

Hi,

For better solution why cant you give a parameter in the selection screen asking for the file path.

Please use CL_GUI_FRONTED_SERVICES=>FILE_SAVE_DIALOG for getting the file path at the selection on value request for that parameter.

If you do like this, in the GUI_DOWNLOAD you need to pass this filepath only.

With Regards,

Sumodh.P