Variante 1 (OPEN DATASET, ohne Berechtigungsprüfung)
DATA(lv_file) = '/usr/sap/tmp/file.txt'.
* Datei auf dem Appl.-Server vorhanden -> Datei testweise öffnen und prüfen
OPEN DATASET lv_file FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.
IF sy-subrc = 0.
CLOSE DATASET lv_file.
WRITE: / |File exists.|.
ELSE.
WRITE: / |File doesn't exist.|.
ENDIF.
Variante 2 (PFL_CHECK_OS_FILE_EXISTENCE mit Berechtigungsprüfung für S_RZL_ADM ACTVT 01)
DATA: lv_file TYPE pfebackuppro VALUE '/usr/sap/tmp/file.txt'.
DATA: lv_exists TYPE abap_bool.
CALL FUNCTION 'PFL_CHECK_OS_FILE_EXISTENCE'
EXPORTING
long_filename = lv_file
IMPORTING
file_exists = lv_exists
EXCEPTIONS
authorization_missing = 1
OTHERS = 2.
IF sy-subrc = 0.
IF lv_exists = abap_true.
WRITE: / |File exists.|.
ELSE.
WRITE: / |File doesn't exist.|.
ENDIF.
ELSE.
WRITE: / 'Error:', sy-subrc.
ENDIF.