2009 Nov 12 2:06 PM
Ho to everybody
I would ask you if exist a function to check if it is available a file in local pc.
I tried with this script but it doen't work
v_path = 'c:\Windowsss\notepad.exe'.
DATA msg_text(50).
OPEN DATASET v_path FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE MESSAGE msg_text.
IF sy-subrc NE 0.
WRITE: 'File cannot be opened for reason : ', msg_text.
EXIT.
ELSE.
CLOSE DATASET v_path.
ENDIF.
Thanks in advance.
2009 Nov 12 2:09 PM
Use class CL_GUI_FRONTEND_SERVICES and the method FILE_EXIST
CLASS cl_gui_frontend_services DEFINITION LOAD.
PARAMETERS: p_file TYPE char80.
DATA: l_string TYPE string,
l_result.
l_string = p_file.
l_result = cl_gui_frontend_services=>file_exist( l_string ).
WRITE l_result.Edited by: Ramiro Escamilla on Nov 12, 2009 8:12 AM
Add example
2009 Nov 12 2:09 PM
Use class CL_GUI_FRONTEND_SERVICES and the method FILE_EXIST
CLASS cl_gui_frontend_services DEFINITION LOAD.
PARAMETERS: p_file TYPE char80.
DATA: l_string TYPE string,
l_result.
l_string = p_file.
l_result = cl_gui_frontend_services=>file_exist( l_string ).
WRITE l_result.Edited by: Ramiro Escamilla on Nov 12, 2009 8:12 AM
Add example
2009 Nov 12 2:16 PM
2009 Nov 12 2:20 PM
Hi,
OPEN DATASET is used for applicatio server file read. For reading files on presentation server, use method FILE_EXISTS of class CL_GUI_FRONTEND_SERVICES.
Regards,
Nilesh.
2009 Nov 12 2:16 PM
Hi Giorgio,
Please make use of method FILE_EXIST of class CL_GUI_FRONTEND_SERVICES. A small code snippet for your reference.
FORM validate_pre_file USING fp_name TYPE rlgrap-filename.
DATA : l_result,
l_filename TYPE string.
l_filename = fp_name.
CLEAR l_result.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = l_filename
RECEIVING
result = l_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE s007 DISPLAY LIKE c_e.
LEAVE LIST-PROCESSING.
ELSEIF l_result IS INITIAL.
MESSAGE s008 DISPLAY LIKE c_e.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " validate_pre_file_hdr
Please set it to resolved if it helps you.
Regards
Abhii...
2009 Nov 12 2:16 PM
Hi ,
Use the method CALL METHOD cl_gui_frontend_services=>file_open_dialog .
Thank you,
Gangadhar.S
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |