‎2009 Apr 15 1:09 PM
Hi All,
Is there any check for right or wrong file path.
for exa.
I have decleared
PARAMETER : p_file LIKE rlgrap-filename .
and give f4 help
SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
CHANGING
file_name = p_file.
but when I give only text.txt in file path it is giving succesful message.
That time it should give error.
Please tell me the solution.
‎2009 Apr 15 1:35 PM
Hello,
You can use the method FILE_EXIST of the class CL_GUI_FRONTEND_SERVICES.
TYPE-POOL: abap.
PARAMETER : p_file LIKE rlgrap-filename .
DATA:
rcbool type ABAP_BOOL,
v_file TYPE string.
v_file = p_file.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
EXPORTING
FILE = v_file
RECEIVING
RESULT = rcbool
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
WRONG_PARAMETER = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF sy-subrc <> 0.
" Do your error handling here
ENDIF.BR,
Suhas
‎2009 Apr 15 1:12 PM
PARAMETERS: p_path LIKE rlgrap-filename OBLIGATORY.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
file_name = p_path.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_path
i_begin_col = 1
i_begin_row = p_start
i_end_col = 6
i_end_row = p_end
TABLES
intern = it_excel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE i001(ZCS).
"i001(zmm01) 'File not exsits!!Please check again'.
CLEAR p_path.
CALL SELECTION-SCREEN 1000.
ENDIF.
‎2009 Apr 15 1:13 PM
It is custom developed error checks. Based on the ur business create folder in a common drive and make sure the user is picking the file from this folder path.
‎2009 Apr 15 1:19 PM
hi AMar,
PC_CHECK_DRIVE "check drive
PC_CHECK_PATH "check Path
PC_CHECK_FILENAME "check file name
PC_CHECK_EXTENSION "Check extension ex:-xls,dat,csv
PC_CHECK_PATH_WITH_DRIVE ""check drive and path
PC_CHECK_FILENAME_WITH_EXT
PC_BUILD_COMPLETE_FILENAME
PC_SPLIT_COMPLETE_FILENAME
Reagrds,
Prabhudas
‎2009 Apr 15 1:21 PM
Hi,
KD_GET_FILENAME_ON_F4 just gives file path popup.....
but when u provide the same file path to GUI_UPLOAD , an exception ll get triggered saying required file path does not exist.
There u can identify the file path error.
Regards,
Ajit.
‎2009 Apr 15 1:31 PM
hi do liike this ..
use this 'SO_SPLIT_FILE_AND_PATH' and put a message if there is not a file
‎2009 Apr 15 1:33 PM
Hi,
Try using
CALL METHOD cl_gui_frontend_services=>directory_exist
Hope it will help you
Regards
Natasha Garg
‎2009 Apr 15 1:35 PM
Hello,
You can use the method FILE_EXIST of the class CL_GUI_FRONTEND_SERVICES.
TYPE-POOL: abap.
PARAMETER : p_file LIKE rlgrap-filename .
DATA:
rcbool type ABAP_BOOL,
v_file TYPE string.
v_file = p_file.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
EXPORTING
FILE = v_file
RECEIVING
RESULT = rcbool
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
WRONG_PARAMETER = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF sy-subrc <> 0.
" Do your error handling here
ENDIF.BR,
Suhas
‎2009 Apr 15 1:40 PM
hi
u can use CL_GUI_FRONTEND_SERVICES=>FILE_EXIST for file and CL_GUI_FRONTEND_SERVICES=>DIRECTRY_EXIST for directry
~linganna