Skip to Content
avatar image
Former Member

Using wild characters to pick up files from Local desktop file directory

Hi all,

My flat files are on my local desktop .

Let's say I have 3 files starting with the letter 'T'.

Titan1.txt

Titan2.txt

Titan3.txt

I need to use wild characters and pick up all 3 files by giving 'T*.txt'

I would like to know how to search my directory ?

Please guide me and give some pointers.

Warm regards,

Hari Kiran

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 21, 2010 at 06:19 AM

    You can pass 'T*.TXT' to the FILTER param of the method DIRECTORY_LIST_FILES.

    No need to take data into the internal table & process it.

    CALL METHOD cl_gui_frontend_services=>directory_list_files
    EXPORTING
    directory = dir
    filter = 'T*.TXT'
    files_only = 'X' 
    CHANGING
    file_table = it_pfiles
    count = count
    EXCEPTIONS
    cntl_error = 1
    directory_list_files_failed = 2
    wrong_parameter = 3
    error_no_gui = 4
    not_supported_by_gui = 5
    OTHERS = 6.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 21, 2010 at 06:09 AM

    Hi all,

    I found this .

    Following will help to search the directory or path given by me.

    CALL METHOD cl_gui_frontend_services=>directory_list_files

    EXPORTING

    directory = dir

    files_only = 'X' CHANGING

    file_table = it_pfiles

    count = count

    EXCEPTIONS

    cntl_error = 1

    directory_list_files_failed = 2

    wrong_parameter = 3

    error_no_gui = 4

    not_supported_by_gui = 5

    OTHERS = 6.

    'dir' contains my file path.

    dir TYPE string VALUE 'C:\temp\'.

    it_pfiles will end up having the files in the specified directory.

    I then need to read the internal table for the files using wild characters.

    Warm regards,

    Hari Kiran

    Edited by: HARI KIRAN REDDY on Jun 21, 2010 11:41 AM

    Add comment
    10|10000 characters needed characters exceeded