Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Parameter for file name with F$ ffunctionality

Hi all,

I want to read a file name as an input. I tried the following syntax :

<b>parameters : p_file type RLGRAP-FILENAME.</b>

But I need F4 functionality too. Does any can provide me some inputs on this.

Thanks and regards,


Former Member
Former Member replied

try this:


  • Local variable declaration

DATA: l_title TYPE string, " Title of dialog

" window

l_filename TYPE file_table, " For getting selected

" File name

l_filefilter TYPE string, " File Filter-excel

" files

l_filerc TYPE i, " Return Code

l_fileaction TYPE i. " User Action

*Internal table for getting the File name in the file selection

*dialog box

DATA: l_filetable TYPE filetable.

  • The method 'file_open_dialog' of class 'cl_gui_frontend_services'

  • is used for displaying the file selection dialog box.

CLASS cl_gui_frontend_services DEFINITION LOAD.

  • Move the title text from the text element to local variable

  • of type string

l_title = 'Select File'.

  • Setting the File Filter to Excel Files

l_filefilter = cl_gui_frontend_services=>filetype_all.

  • Display the file open dialog

CALL METHOD cl_gui_frontend_services=>file_open_dialog


window_title = l_title " Title of the file

" Selection window

default_extension = c_extension " Ext. of the file

file_filter = l_filefilter " All files to

" be displayed in the

" selection window


file_table = l_filetable " Contains the filename

" selected

rc = l_filerc " Return code

user_action = l_fileaction " User action


file_open_dialog_failed = 1

cntl_error = 2

error_no_gui = 3

not_supported_by_gui = 4.

IF sy-subrc = 0.

  • On File name Selection

IF l_fileaction EQ cl_gui_frontend_services=>action_ok.

CHECK NOT l_filetable[] IS INITIAL.

  • Only one file can be selected at a time so read

  • the first entry of the table l_filetable

READ TABLE l_filetable INTO l_filename INDEX 1.

  • No sy-subrc check

  • Displaying the selected file name in the File name Parameter

  • on the screen

p_file = l_filename-filename.



0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question