‎2007 Mar 02 3:39 PM
I am trying to write a upload program. The file to be uploaded has date and time stamp.
READ DATASET xxxxx_yyyymmdd_hhmmss.dat INTO xxxxxx.
How do I read file if I don't know time.
Thanks,
Amol..
‎2007 Mar 02 3:41 PM
‎2007 Mar 02 3:41 PM
‎2007 Mar 02 3:42 PM
There can be multiple file with different time stamp.
Thanks,
AP
‎2007 Mar 02 3:44 PM
If it is only file, then you can do something like this. Get a listing of the files in the directory, then read the first line of the internal table of files, and use that name to concatenate with the file path. Then open it, read it, and close it.
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/'.
* Get all files from directory.
call function 'RZL_READ_DIR_LOCAL'
exporting
name = p_path
tables
file_tbl = ifile
exceptions
argument_error = 1
not_found = 2
others = 3.
* Read the one and only line to get the filename.
read table ifile index 1.
* Concatetnant with path
concatenate p_path ifile-name into p_file.
* Upload the 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.
* Write it out.
loop at itab.
write:/ itab.
endloop.
If it is more than one file, you can do the same, but i would assume that it is important as to which one is done first and second, in that case, you could sort the file names as you need to.
Regards,
Rich Heilman
Message was edited by:
Rich Heilman
‎2007 Mar 02 3:42 PM
HI AP,
first fetch the file with the help of FM F4_dxfilename_toprecursion which is for F4 help of application file and then read the required file ...
Regards,
Santosh
Message was edited by:
Santosh Kumar Patha
‎2007 Mar 02 3:44 PM
Hi,
You can use the function module 'RZL_READ_DIR_LOCAL'. If you pass the directory name in the function call it will return a list fo files in that directory.
Regards,
Ferry Lianto
‎2007 Mar 02 3:46 PM
Hi Amol,
You can retrieve application server file names in the F4 help function by submitting program rs_get_f4_dir_from_applserv.
<b>Code</b>
SELECTION-SCREEN BEGIN OF BLOCK 002 WITH FRAME TITLE text-002.
PARAMETERS : p_aps LIKE rlgrap-filename MODIF ID pth .
SELECTION-SCREEN END OF BLOCK 002.
DATA : path_name(150) TYPE c.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_aps.
SUBMIT rs_get_f4_dir_from_applserv AND RETURN.
IMPORT path_name FROM MEMORY ID 'PATH_NAME_SDL'.
p_aps = path_name.So here, P_APS will have the file name then write the DATASETS Code
Regards
Sudheer