06-21-2010 6:49 AM
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
06-21-2010 7: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.
06-21-2010 7: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
06-21-2010 7: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.
06-21-2010 7:23 AM
Yes, Suhas.
You are right.
That's even better.
Thanks a ton.
Warm regards,
Hari Kiran