[ABAP] Prüfen, ob Datei existiert (FileExists)

PARAMETERS: p_fname TYPE file_table-filename OBLIGATORY LOWER CASE.
  
AT SELECTION-SCREEN.
  DATA: lv_res TYPE boolean.

  TRY.
    cl_gui_frontend_services=>file_exist(
      EXPORTING
        file                 = | { p_fname } |
      RECEIVING
        result               = lv_res ).
    CATCH cx_root INTO DATA(e_text).
      MESSAGE e_text->get_text( ) TYPE 'I'.
  ENDTRY.

  IF lv_res NE abap_true.
    WRITE: / 'Check file!'.
  ENDIF.