09-24-2008 3:37 PM
Hello gurus,
I'm trying to use CL_GUI_FRONTEND_SERVICES to give users a popup file selector box and select one file.
That file will be used later in the program for either uploading or downloading data.
I can't seem to find a method that does what I want.
Have you any suggestions?
Thanks
Ed Baker
09-24-2008 3:42 PM
Use method FILE_OPEN_DIALOG of the CL_GUI_FRONTEND_SERVICES.
Like:
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'Select a file'
DEFAULT_FILENAME = L_TYPE
CHANGING
FILE_TABLE = LT_FILES
RC = RC
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE E398(00) WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get file selected
READ TABLE LT_FILES INDEX 1 INTO LW_FILES.
MOVE LW_FILES-FILENAME TO P_LFILE.
Regards,
Naimesh Patel
09-24-2008 3:42 PM
Use method FILE_OPEN_DIALOG of the CL_GUI_FRONTEND_SERVICES.
Like:
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'Select a file'
DEFAULT_FILENAME = L_TYPE
CHANGING
FILE_TABLE = LT_FILES
RC = RC
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE E398(00) WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get file selected
READ TABLE LT_FILES INDEX 1 INTO LW_FILES.
MOVE LW_FILES-FILENAME TO P_LFILE.
Regards,
Naimesh Patel
09-24-2008 4:17 PM
Hi. Thanks for replying.
I should have mentioned what I'd done so far.
My biggest problem is that the method doesn't seem to pay any attention to the default directory.
The default directory is always whatever the user last used when he left Windows Explorer.
That seems odd to me.
CONCATENATE 'C:\Documents and Settings\edward.baker\'
'My Documents\Thermo_Upgrade_Project\vbis_replacement\'
INTO default_directory.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'File Dialog'
default_extension = '*.xml'
* default_filename =
file_filter = '*.xml'
* with_encoding =
initial_directory = default_directory
* multiselection =
CHANGING
file_table = lt_filetable
rc = lv_rc
* user_action =
* file_encoding =
09-24-2008 4:29 PM
You can use the DIRECTORY_SET_CURRENT. In the description, it says don't use but it is working.
Call this method before the FILE_OPEN_DIALOG
data: l_rc type sy-subrc.
CALL METHOD cl_gui_frontend_services=>directory_set_current
EXPORTING
current_directory = 'C:\temp'
changing
rc = l_rc.
Regards,
Naimesh Patel.
09-24-2008 4:44 PM
09-24-2008 4:05 PM