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

FILENAME_GET

Former Member
0 Likes
991

Hi all,

there is a function called FILENAME_GET and it gives a pop-up where the user can give a filename.

I do not want the user to write the complete path to the file,

so I would like to know if there is a function which let's the user select a file on his/her System

through browsing (like windows open file dialog) and returns the full path to the file?

greetings Fred.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
898

hi fred,

check the method

CL_GUI_FRONTEND_SERVICES->FILE_OPEN_DIALOG.

CALL METHOD cl_gui_frontend_services=>file_open_dialog

EXPORTING

window_title = 'Import from a local file'

default_extension = 'DAT'

  • DEFAULT_FILENAME =

initial_directory = 'C:\'

  • MULTISELECTION =

  • WITH_ENCODING =

CHANGING

file_table = l_table

rc = l_rc

  • USER_ACTION =

  • FILE_ENCODING =

EXCEPTIONS

file_open_dialog_failed = 1

cntl_error = 2

error_no_gui = 3

not_supported_by_gui = 4

OTHERS = 5

.

Message was edited by: Priya

Hi all,

there is a function called FILENAME_GET and it gives a pop-up where the user can give a filename.

I do not want the user to write the complete path to the file,

so I would like to know if there is a function which let's the user select a file on his/her System

through browsing (like windows open file dialog) and returns the full path to the file?

greetings Fred.

6 REPLIES 6
Read only

Former Member
0 Likes
898
*---------------Popup for file name---------------------*
  CONSTANTS :
         lc_dft_ext    TYPE string VALUE 'XLS',
         lc_file_flt   TYPE string VALUE '*.xls',
         lc_int_drc    TYPE string VALUE 'C:'.

  DATA : lv_win_title  TYPE string,
         lv_file_name  TYPE string,
         lv_dft_fname  TYPE string,
         lv_fname      TYPE string,
         lv_path       TYPE string.

  CLEAR: lv_fname,
         lv_path,
         lv_file_name,
         lv_win_title,
         lv_dft_fname.

*---------------Set File Details F4 Based on Report Type--------------*
  IF xv_indicator = lc_s.
    lv_win_title = text-045.
    lv_dft_fname = text-038.
  ELSE.
    lv_win_title = text-044.
    lv_dft_fname = text-033.
  ENDIF.


  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      window_title         = lv_win_title
      default_extension    = lc_dft_ext
      default_file_name    = lv_dft_fname
      file_filter          = lc_file_flt
      initial_directory    = lc_int_drc
      prompt_on_overwrite  = lc_true
    CHANGING
      filename             = lv_fname
      path                 = lv_path
      fullpath             = lv_file_name
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      not_supported_by_gui = 3
      OTHERS               = 4.

  IF sy-subrc <> 0 OR lv_fname     IS INITIAL
                   OR lv_path      IS INITIAL
                   OR lv_file_name IS INITIAL.

    CLEAR xyv_filepath.

  ELSE.
*---FilePath
    xyv_filepath = lv_file_name.
  ENDIF.
Read only

Former Member
0 Likes
899

hi fred,

check the method

CL_GUI_FRONTEND_SERVICES->FILE_OPEN_DIALOG.

CALL METHOD cl_gui_frontend_services=>file_open_dialog

EXPORTING

window_title = 'Import from a local file'

default_extension = 'DAT'

  • DEFAULT_FILENAME =

initial_directory = 'C:\'

  • MULTISELECTION =

  • WITH_ENCODING =

CHANGING

file_table = l_table

rc = l_rc

  • USER_ACTION =

  • FILE_ENCODING =

EXCEPTIONS

file_open_dialog_failed = 1

cntl_error = 2

error_no_gui = 3

not_supported_by_gui = 4

OTHERS = 5

.

Message was edited by: Priya

Read only

Former Member
0 Likes
898

try this

GUI_FILE_SAVE_DIALOG

Read only

Former Member
0 Likes
898

Hi Fred,

Check out for FM: <b>F4_FILENAME</b>

Regds,

Akshay Bhagwat

Note: Pls mark helpful answers.

Read only

Former Member
0 Likes
898

Whether it is a class-method / function, the user will have the option writing the file name.

But you can always validate the existence of the file and throw a error or call the same code again to select the file.

Regards,

Ravi

Read only

LucianoBentiveg
Active Contributor
0 Likes
898

Try this one F4_DXFILENAME_TOPRECURSION.

Work with app server too.

Regards.