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: 

Get all files from Directory

Former Member
0 Kudos

Hi All,

My requirment is to get releted files from Local Directory.

For Example Path is "D/Data/"

in this path there is files like

abc123_de.txt

abc123_en.txt

xyz123_de.txt

abc123_pt.txt

xyz123_en.txt

pqr123_en.txt

bcg234_en.txt

sjd467_en.txt

Now i want to use only files which are strart from abc123 and use their data.

From which FM i can do it or how can i do this?

Thanks,

Mahipalsinh

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

just try this method.

CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES

I think that should fit your requirement.

regards

Alex

4 REPLIES 4

Former Member
0 Kudos

Hi,

just try this method.

CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES

I think that should fit your requirement.

regards

Alex

Former Member
0 Kudos

use Function Module

call function 'TMP_GUI_DIRECTORY_LIST_FILES'


nishantbansal91
Active Contributor
0 Kudos

Dear Mahipalsinh,

I have got the same requirement some days back, i think there is no FM for your requirement. so what i did, i have get all the files using below FM and Concatenate the ABC.

Please use the Below FM, because if the file name is above that 50 character that time always it gives the full file name. Please check, if u used the other one for getting the Files.

   CALL FUNCTION 'EPS2_GET_DIRECTORY_LISTING'

     EXPORTING

       iv_dir_name            = lv_dir_name

     TABLES

       dir_list               = lt_file_name

     EXCEPTIONS

       invalid_eps_subdir     = 1

       sapgparam_failed       = 2

       build_directory_failed = 3

       no_authorization       = 4

       read_directory_failed  = 5

       too_many_read_errors   = 6

       empty_directory_list   = 7

       OTHERS                 = 8.

   IF sy-subrc <> 0.

* Implement suitable error handling here

   ENDIF.



For reading Specific Files.


CONCATENATE 'AP' lv_internal_date INTO lv_filename.

         LOOP AT  lt_file_name INTO ls_file_name.

           lv_index = sy-tabix.

           IF ls_file_name-name CS lv_filename.

          " PUT YOUR LOGIC

          endif.

     endloop.

Thanks,
Nishant

Former Member
0 Kudos

Thanks all of you  i solved it