cancel
Showing results for 
Search instead for 
Did you mean: 

F4 search Help For File Name

Former Member
0 Kudos

Hello,

Is there any function module for F4 help to get the file name parameter on the selection Screen.

Thanks

Viky

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

There are many standard function modules avaiable in the SAP system.

Refer to the following function modules in SE37 Transaction.

<u>WS_FILE_GET

call method cl_gui_frontend_services=>file_open_dialog</u>

Please do a where-used list to find how to use the function module according to your business requirements.

<i>Sample code -></i>

<b>For opening any file on your PC - using File_open_dialog</b>

form get_filename  using value(p_flag) type rprxxxxx-kr_feld4
                   changing p_filename type rlgrap-filename.
 
 
  class cl_gui_frontend_services definition load.
 
  data: l_filefilter   type string,
        l_filename     type string,
        l_filetable    type filetable,
        l_rc           type i,
        l_user_action  type i,
        l_window_title type string.
 
* only when local
  check p_flag is initial.
 
* Set data type drop-down and popup title
  concatenate cl_gui_frontend_services=>filetype_text
              cl_gui_frontend_services=>filetype_all
          into l_filefilter.
  l_window_title = text-f02.
 
* Dialogue
  call method cl_gui_frontend_services=>file_open_dialog
    exporting
      window_title            = l_window_title
      default_extension       = con_ext
*     DEFAULT_FILENAME        =
      file_filter             = l_filefilter
      initial_directory       = con_init_dir
*     MULTISELECTION          =
    changing
      file_table              = l_filetable
      rc                      = l_rc
      user_action             = l_user_action
    exceptions
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      others                  = 5
          .
  if sy-subrc <> 0.
    message e899(5a) with 'Error'.
  endif.
 
* dialogue not canceled
  check l_user_action <> cl_gui_frontend_services=>action_cancel.
 
  read table l_filetable into l_filename index 1.
  check sy-subrc = 0.
  p_filename = l_filename.
 
endform.                    " get_filename

Let me know incase you face any issues.

Regards

- Atul

Former Member
0 Kudos

Thanks Atul,

what is p_flag in the form. what shud be its value

Viky

Former Member
0 Kudos

Hi

Thanks.

The value of P_flag will be something like this.

<u>Add this sample code.</u>


*--- Source file is not local
parameters: pa_fnl like rprxxxxx-kr_feld4 default space
            user-command fire.
*--- Source file path and name
parameters: pa_fin like rlgrap-filename.


*--- F4 Search for file name
at selection-screen on value-request for pa_fin.
  perform get_filename using pa_fnl
                       changing pa_fin.

Hope this will help.

Regards

- Atul

Answers (1)

Answers (1)

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please check this FM F4_FILENAME (for PC files) and F4_DXFILENAME_TOPRECURSION (for application server files).


REPORT Z_TEST.

DATA f_name TYPE STRING.

PARAMETERS p_file like rlgrap-filename DEFAULT 'c:test.xls'.
 
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = syst-repid
dynpro_number = syst-dynnr
field_name = 'p_file'
importing
file_name = p_file.
 
start-of-selection.

f_name = p_file.
write:/ f_name.

and


REPORT Z_TEST.

parameters : p_file like rlgrap-filename.
 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
 
DATA: c_fnh_mask TYPE dxfields-filemask VALUE '*.*',
  search_dir TYPE dxfields-longpath VALUE '/sapglobal/users',
  file_path LIKE dxfields-longpath.
 
  CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
    EXPORTING
      i_location_flag = 'A'
      i_server        = ' '
      i_path          = search_dir
      filemask        = c_fnh_mask
      fileoperation   = 'R'
    IMPORTING
      o_path          = file_path
    EXCEPTIONS
      rfc_error       = 1
      OTHERS          = 2.

  IF sy-subrc EQ 0.
    p_file = file_path.
  ENDIF.

Regards,

Ferry Lianto