SELECT A FOLDER FROM PROGRAM:
The below program will create a input selection that will pop up the folder selection box.
REPORT Z_ABAP_FOLDER_SELECTION.
CONSTANTS: c_default_folder TYPE rlgrap-filename VALUE 'C:\'.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
PARAMETERS : p_folder LIKE rlgrap-filename OBLIGATORY DEFAULT c_default_folder.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
PERFORM select_folder CHANGING p_folder.
FORM select_folder CHANGING p_p_folder.
DATA: l_path TYPE string.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = 'Select Folder'
initial_folder = 'C:\'
CHANGING
selected_folder = l_path
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
MOVE l_path TO p_p_folder.
ENDFORM. " SELECT_FOLDER
OUTPUT:
The below program will create a input selection that will pop up the folder selection box.
REPORT Z_ABAP_FOLDER_SELECTION.
CONSTANTS: c_default_folder TYPE rlgrap-filename VALUE 'C:\'.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
PARAMETERS : p_folder LIKE rlgrap-filename OBLIGATORY DEFAULT c_default_folder.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
PERFORM select_folder CHANGING p_folder.
FORM select_folder CHANGING p_p_folder.
DATA: l_path TYPE string.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = 'Select Folder'
initial_folder = 'C:\'
CHANGING
selected_folder = l_path
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
MOVE l_path TO p_p_folder.
ENDFORM. " SELECT_FOLDER
OUTPUT: