2006 Jul 26 4:24 PM
Hi,
Can anyone help me in finding if there's any way to read all files in a folder on the server?Any Function module or anything.
Thanks
2006 Jul 26 4:37 PM
On App server? Try this sample program.
report zrich_0001 .
data: begin of itab occurs 0,
rec(1000) type c,
end of itab.
data: wa(1000) type c.
data: p_file type localfile.
data: ifile type table of salfldir with header line.
parameters: p_path type salfile-longname
default '/usr/sap/TST/DVEBMGS01/data/'.
call function 'RZL_READ_DIR_LOCAL'
exporting
name = p_path
tables
file_tbl = ifile
exceptions
argument_error = 1
not_found = 2
others = 3.
loop at ifile.
format hotspot on.
write:/ ifile-name.
hide ifile-name.
format hotspot off.
endloop.
at line-selection.
concatenate p_path ifile-name into p_file.
clear itab. refresh itab.
open dataset p_file for input in text mode.
if sy-subrc = 0.
do.
read dataset p_file into wa.
if sy-subrc <> 0.
exit.
endif.
itab-rec = wa.
append itab.
enddo.
endif.
close dataset p_file.
loop at itab.
write:/ itab.
endloop.
Regards,
Rich Heilman
Hi,
Can anyone help me in finding if there's any way to read all files in a folder on the server?Any Function module or anything.
Thanks
2006 Jul 26 4:28 PM
Hi
Try the method DIRECTORY_LIST_FILES of class CL_GUI_FRONTEND_SERVICES for Presentation server or/and fm SUBST_GET_FILE_LIST for Application server
Max
2006 Jul 26 4:33 PM
hi sirisha,
check the FM 'RZL_READ_DIR_LOCAL'
hope this helps,
do reward if it helps,
priya.
2006 Jul 26 4:37 PM
On App server? Try this sample program.
report zrich_0001 .
data: begin of itab occurs 0,
rec(1000) type c,
end of itab.
data: wa(1000) type c.
data: p_file type localfile.
data: ifile type table of salfldir with header line.
parameters: p_path type salfile-longname
default '/usr/sap/TST/DVEBMGS01/data/'.
call function 'RZL_READ_DIR_LOCAL'
exporting
name = p_path
tables
file_tbl = ifile
exceptions
argument_error = 1
not_found = 2
others = 3.
loop at ifile.
format hotspot on.
write:/ ifile-name.
hide ifile-name.
format hotspot off.
endloop.
at line-selection.
concatenate p_path ifile-name into p_file.
clear itab. refresh itab.
open dataset p_file for input in text mode.
if sy-subrc = 0.
do.
read dataset p_file into wa.
if sy-subrc <> 0.
exit.
endif.
itab-rec = wa.
append itab.
enddo.
endif.
close dataset p_file.
loop at itab.
write:/ itab.
endloop.
Regards,
Rich Heilman
2022 Mar 09 8:44 AM
Problem with this FM is that it can only have 32 character filename, is there any other FM which can help choose files having long filenames?
2022 Mar 09 8:46 AM
2006 Jul 26 5:11 PM
2009 Jul 07 12:58 PM
Wrong thread.
Edited by: Moisés Lorenzo on Jul 7, 2009 1:01 PM