Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

FileFilter in cl_gui_frontend_services=>directory_list_files doesn't work

ventior
Explorer
0 Kudos

For some reason whenever I use a file filter in the function "directory_list_files" of "cl_gui_frontend_services" it doesn't seem to work, while in methods like "file_open_dialog" there is no such problem.

If I leave out the filter in the code below it lists all files in the directory as usual, but when I use the filetype_excel filter all files vanish, including XLSX and XLSM files while still giving a sy-subrc of 0.

Is there a note regarding this problem? I read of note 864592, but it seemingly has been removed.

cl_gui_frontend_services=>directory_list_files(
  EXPORTING
    directory                   = lv_directory                 " Directory To Search
    files_only                  = abap_true
    filter                      = cl_gui_frontend_services=>filetype_excel          " File filter
  CHANGING
    file_table                  = lt_file_table               " Return Table for the Found Files
    count                       = lv_count                 " Number of Files/Dir Found
  EXCEPTIONS
    cntl_error                  = 1                " Control error
    directory_list_files_failed = 2                " Could not list files in the directory
    wrong_parameter             = 3                " Incorrect parameter combination
    error_no_gui                = 4                " No GUI available
    not_supported_by_gui        = 5                " GUI does not support this
    OTHERS                      = 6 ).

    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.<br>
1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor

Try using filter '*.XLS*' it worked on my systems.

4 REPLIES 4

Sandra_Rossi
Active Contributor

What about all the other SAP notes?

2868986 - DIRECTORY_LIST_FILES method is not working with multiple filter values

etc.

Do you have a S-User?

raymond_giuseppi
Active Contributor

Try using filter '*.XLS*' it worked on my systems.

Yes, works perfectly along the note sandrarossi commented. Thank you for your help!

ventior
Explorer

It seems this particular note has flown over my head. Thank you for showing me.