2009 Mar 26 9:27 AM
hi,
I need to validate if a directory or file path exist on application server. How do we do that?
thanks.
Use this fm.
FILE_GET_NAME
If sy-subrc NE 0.
Message 'File not found' type 'E'.
Endif.
2009 Mar 26 9:30 AM
Hi,
OPEN DATASET P_FILENAME for INPUT in TEXT MODE .
If SY-SUBRC EQ 0.
* File Exists
ELSE.
* File does not exit.
ENDIF.
or
Check this Fm 'RZL_READ_DIR'
'RZL_READ_FILE'
2009 Mar 26 9:33 AM
Use this fm.
FILE_GET_NAME
If sy-subrc NE 0.
Message 'File not found' type 'E'.
Endif.
2009 Mar 26 9:35 AM
DATA:
ltp_bom TYPE sychar01,
ltp_encoding TYPE sychar01,
ltp_codepage TYPE cpcodepage.
Processing --------------------------------------------------------- *
TRY.
CALL METHOD cl_abap_file_utilities=>check_utf8
EXPORTING
file_name = itp_filename
max_kb = -1
all_if_7bit_ascii = abap_true
IMPORTING
bom = ltp_bom
encoding = ltp_encoding.
CATCH cx_sy_file_open .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING file_open_error.
CATCH cx_sy_file_authority .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING file_authority_error.
CATCH cx_sy_file_io .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING file_io_error.
ENDTRY.
2009 Mar 26 9:38 AM
priyanka,
You can put the open data set in try --- catch block and validate.
TRY.
OPEN DATASET P_FILENAME for INPUT in TEXT MODE .
CATCH cx_sy-file_open*
perform error_message.
ENDTRY
2009 Mar 26 9:39 AM
2009 Mar 26 9:50 AM
2009 Mar 26 9:57 AM
Hi ,
You can try using these two Function Modules:
To have an f4 help on the application server file
:F4_DXFILENAME_TOPRECURSION
And to validate the path use:
FILE_GET_NAME_USING_PATH
Hope it helps
Regards
Mansi
2009 Mar 26 10:06 AM
Hi
Use the FM RZL_READ_DIR to get the file details of a directory.
Then you can check your file is exist or not.
2009 Mar 26 10:11 AM
Hi,
You can use this FM:
CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
EXPORTING
file_name =
dir_name =
EXCEPTIONS
OTHERS = 3.
IF sy-subrc NE 0.
c_error = 'X'.
ENDIF.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |