05-19-2008 3:40 PM
Hi ,
We have a scenario where we have to upload data from around 500 files which will be dumpted at one location.
We can have a proper name also for them but is it possible that all will be read and updated .
Incase you have any code related to same , please share.
Regards
Rahul
05-19-2008 4:02 PM
Rahul,
Am assuming that in your case all the files are dumped on the application server. If that is the case use the below function module to get all the file names from the dumped directory.
EPS_GET_DIRECTORY_LISTING
Now read file names one by one and use OPEN DATASET <filename>................CLOSE DATASET for each file.
********Reward points if useful.
Regards,
Kiran Bobbala.
05-19-2008 4:37 PM
Hi Rahul,
this code is what u are searching for.
Reward Points if it is usefull, are very appreciated
Andrea
FORM get_all_files .
DATA: BEGIN OF file,
dirname(75) TYPE c, " name of directory. (possibly truncated.)
name(75) TYPE c, " name of entry. (possibly truncated.)
type(10) TYPE c, " type of entry.
len(8) TYPE p, " length in bytes.
owner(8) TYPE c, " owner of the entry.
mtime(6) TYPE p, " last modification date, seconds since 1970
mode(9) TYPE c, " like "rwx-r-x--x": protection mode.
useable(1) TYPE c,
subrc(4) TYPE c,
errno(3) TYPE c,
errmsg(40) TYPE c,
mod_date TYPE d,
mod_time(8) TYPE c, " hh:mm:ss
seen(1) TYPE c,
changed(1) TYPE c,
END OF file.
DATA: BEGIN OF searchpoints OCCURS 10,
dirname(75) TYPE c, " name of directory.
sp_name(75) TYPE c, " name of entry. (may end with *)
sp_cs(10) TYPE c, " ContainsString pattern for name.
END OF searchpoints.
DATA len TYPE i.
*Lettura della data/ora del file
searchpoints-dirname = pathdata. "For example /usr/sap/tmp/
CALL 'C_DIR_READ_FINISH' " just to be sure
ID 'ERRNO' FIELD file-errno
ID 'ERRMSG' FIELD file-errmsg.
CALL 'C_DIR_READ_START' ID 'DIR' FIELD searchpoints-dirname
ID 'FILE' FIELD searchpoints-sp_name
ID 'ERRNO' FIELD file-errno
ID 'ERRMSG' FIELD file-errmsg.
CHECK sy-subrc EQ 0.
DO.
CLEAR file.
CALL 'C_DIR_READ_NEXT'
ID 'TYPE' FIELD file-type
ID 'NAME' FIELD file-name
ID 'LEN' FIELD file-len
ID 'OWNER' FIELD file-owner
ID 'MTIME' FIELD file-mtime
ID 'MODE' FIELD file-mode
ID 'ERRNO' FIELD file-errno
ID 'ERRMSG' FIELD file-errmsg.
IF sy-subrc EQ 0.
IF file-name CS pfname.
len = STRLEN( file-name ).
CHECK len = 12. "Get only files length 12 char -> u can omiss this
CONCATENATE pathdata file-name INTO ilistfile-filename.
APPEND ilistfile. "The file list
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDFORM. " get_all_files