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: 

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

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

SuhaSaha
Advisor
Advisor
0 Kudos

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.

3 REPLIES 3

Former Member
0 Kudos

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

SuhaSaha
Advisor
Advisor
0 Kudos

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.

Former Member
0 Kudos

Yes, Suhas.

You are right.

That's even better.

Thanks a ton.

Warm regards,

Hari Kiran