Skip to end of metadata
Go to start of metadata

FILE_OPEN_DIALOG & FILE_SAVE_DIALOG

Determination of a file name on the presentation server using a file selection dialog.

WS_FILENAME_GET is the obsolete function used for this scope, it has two operation modes: Open and Save

In Open mode

CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
* DEF_FILENAME = ' '
* DEF_PATH = ' '
* MASK = ' '
MODE = 'O'
* TITLE = ' '
IMPORTING
FILENAME = lv_filename
* RC =
* EXCEPTIONS
* INV_WINSYS = 1
* NO_BATCH = 2
* SELECTION_CANCEL = 3
* SELECTION_ERROR = 4
* OTHERS = 5
.

In ECC is necessary to use method FILE_OPEN_DIALOG

DATA: lt_file_table TYPE filetable,
ls_file_table TYPE file_table,
lv_filename TYPE string,
lv_rc TYPE i.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
* EXPORTING
* WINDOW_TITLE =
* DEFAULT_EXTENSION =
* DEFAULT_FILENAME =
* FILE_FILTER =
* WITH_ENCODING =
* INITIAL_DIRECTORY =
* MULTISELECTION =
CHANGING
FILE_TABLE = lt_file_table
RC = lv_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
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
CHECK lv_rc = 1.
READ TABLE lt_file_table INTO ls_file_table INDEX 1.
CHECK sy-subrc = 0.
MOVE ls_file_table-filename TO lv_filename.
ENDIF.

Or you can use this code in order to avoid CHECK statement

IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF lv_rc > 0.
READ TABLE lt_file_table INTO ls_file_table INDEX 1.
MOVE ls_file_table-filename TO lv_filename.
ENDIF.
ENDIF.

In Save mode

CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
* DEF_FILENAME = ' '
* DEF_PATH = ' '
* MASK = ' '
MODE = 'S'
* TITLE = ' '
IMPORTING
FILENAME = lv_filename
* RC =
* EXCEPTIONS
* INV_WINSYS = 1
* NO_BATCH = 2
* SELECTION_CANCEL = 3
* SELECTION_ERROR = 4
* OTHERS = 5
.

In ECC is necessary to use method FILE_SAVE_DIALOG

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
* EXPORTING
* WINDOW_TITLE =
* DEFAULT_EXTENSION =
* DEFAULT_FILENAME =
* FILE_FILTER =
* INITIAL_DIRECTORY =
* PROMPT_ON_OVERWRITE = 'X'
CHANGING
FILENAME = lv_filename
PATH = lv_path
FULLPATH = lv_fullpath
* USER_ACTION =
* FILE_ENCODING =
* EXCEPTION
* CNTL_ERROR = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
* OTHERS = 4 .

This new method give to you the possibility also to gather information about the PATH and the FULLPATH.

  • No labels