how to browse files in sap ABAP OR apply for search help in the file field.
There are simple steps to browse files.
For the Report program you need to use the parameter :
- make parameter of type rlgrap-filename
PARAMETERS : gv_file TYPE rlgrap-filename.
2. Method 1 to browse file – call ‘F4_FILENAME’
AT SELECTION-SCREEN ON VALUE-REQUEST FOR gv_file.
CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* field_name = 'gv_file'
IMPORTING
file_name = gv_file.
For the Report program
Method 2 – browse the file For the Report program, you can use the global class cl_gui_frontend_services of method file_open_dialog .
PARAMETERS : io_file TYPE rlgrap-filename.
Data : lv_filec TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR io_file.
DATA: lv_title TYPE string,
lt_filetable TYPE filetable, "list of files you select in table
lv_rc TYPE i. "record count (directory path and file name)
DATA: wa_filetable LIKE LINE OF lt_filetable.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
* EXPORTING
* window_title = lv_title
* multiselection = abap_true "For multiple selection"
* initial_directory = ' '
CHANGING
file_table = lt_filetable
rc = lv_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc = 0.
READ TABLE lt_filetable INTO wa_filetable INDEX 1.
IF sy-subrc EQ 0.
* lv_file = wa_filetable-filename.
io_file = wa_filetable-filename.
* SET PARAMETER ID 'FIL' FIELD io_file.
IF sy-subrc EQ 0.
lv_filec = io_file.
ENDIF.
ENDIF.
At Selection Screen on Value Request event is used to display the possible values to be entered into the input field(search help).
This Method is for Module Pool Program
Step1: create screen ‘9001’ and make input box of field name ‘io_file’
step2 : after make input box you must declare filename(io_file) in top so that it will copy screen attribute to program attribute .
// YYREX_TOP
Data: IO_FILE type rlgrap-filename.
Step3 : In “PROCESS ON VALUE-REQUEST” write field name which you want to help search help.
// screen
PROCESS ON VALUE-REQUEST.
field IO_FILE module call.
Step 4: In this step you need to call method “method file_open_dialog” of global class “cl_gui_frontend_services“.
MODULE call INPUT.
DATA: lv_title TYPE string,
lt_filetable TYPE filetable, "list of files you select in table
lv_record_count TYPE i."record count (directory path and file name)
DATA: wa_filetable LIKE LINE OF lt_filetable.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
* EXPORTING
* window_title = lv_title
* multiselection = abap_true "For multiple selection"
* initial_directory = ' '
CHANGING
file_table = lt_filetable
rc = lv_record_count
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc = 0.
READ TABLE lt_filetable INTO wa_filetable INDEX 1.
IF sy-subrc EQ 0.
io_file = wa_filetable-filename.
ENDIF.
ENDIF.
ENDMODULE.