‎2006 Sep 04 4:52 PM
Hi Experts,
I have a directory in the application server .
I have some list of files in that directory.
So i have to read the directory first and i have to process the file one by one and i have to upload the data in the file into SAP.This i have to do in background.
Can any body tell me some suggessions on this?
‎2006 Sep 04 5:08 PM
Please take a look at this application server file browser program. You can use this for your requirement, the only difference here is that it provides a list for the user to choose which file to upload, you can simply modify it for your needs.
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
‎2006 Sep 04 5:22 PM
Hi,
Thanks for reply.But my program will run in back ground.
So there won't be any selection-screen in my pgm.
So in that FM if i hardcode the path will it run background?
‎2006 Sep 04 5:30 PM
‎2006 Sep 04 5:31 PM
‎2006 Sep 04 5:10 PM
Hi,
use FM : 'RZL_READ_DIR_LOCAL' to read files on the application server.
check this code :
PARAMETER: p_fdir type pfeflnamel DEFAULT '/usr/sap/tmp'.
data: begin of it_filedir occurs 10.
include structure salfldir.
data: end of it_filedir.
START-OF-SELECTION.
* Get Current Directory Listing for OUT Dir
call function 'RZL_READ_DIR_LOCAL'
exporting
name = p_fdir
tables
file_tbl = it_filedir.
* List of files are contained within table it_filedir
loop at it_filedir.
clear :i_xcontent.
refresh :i_xcontent.
open dataset it_filedir-file for input in text mode.
do.
read dataset it_filedir-file into ls_xcontent-line.
if sy-subrc eq 0.
append ls_xcontent to i_xcontent.
endif.
enddo.
close dataset it_filedir-file.
*Update table with internal table data
modify ztable from table i_xcontent.
endloop.Regards
Appana