‎2006 Jan 04 10:33 AM
Hi i've been asked to make a program that send e-mail with attachments files from a directory on the server,
the file that'll be attach have to be with creation date of the day the program will execute.
i did the part of sending e-mail,my problem is that i don't know how to take the creation date of the file in server(Windows Server).
So if anyone have an idea i'll be more than happy to read a bout it.
thanks.
‎2006 Jan 04 10:39 AM
Dear Gil,
If we can read the property of the file then we can retreive the file creation date. But I'm not sure how to read the file properties in SAP.
regards,
Deva.
‎2006 Jan 04 10:41 AM
Hi,
Please try
CL_GUI_FRONTEND_SERVICES=>FILE_GET_VERSION
CL_GUI_FRONTEND_SERVICES=>FILE_GET_ATTRIBUTES
Hope it helps...
Lokesh
Pls. reward appropriate points
‎2006 Jan 05 7:09 AM
‎2006 Jan 05 7:25 AM
do you want file creation date or program execution date to be added to the file ??
regards,
srikanth
‎2006 Jan 05 7:56 AM
I want file creation date.
and then when the program will run it'll attach all the files of execution date.
10X
‎2006 Jan 05 8:40 AM
Hi Gil,
This will solve your problem :
1. One the selection screen,
Enter PATH
Enter Date (of Creation)
2. The program will list out
a) Files of that date
b) All files & sub-directories under that Path
3. Important Internal Table is : ALLFILE
4. Use this code (Just Copy Paste)
REPORT abc.
*----
DATA
*----
TYPES: name_of_dir(1024) TYPE c,
name_of_file(260) TYPE c,
name_of_path(1285) TYPE c.
DATA: BEGIN OF file,
dirname TYPE name_of_dir, " name of directory. (possibly
" truncated.)
name TYPE name_of_file, " 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 : allfile LIKE file OCCURS 0 WITH HEADER LINE.
*----
SELECTION SCREEN
*----
PARAMETERS : path(260) TYPE c DEFAULT '/usr/sap/trans' LOWER CASE.
PARAMETERS : mydate TYPE sy-datum DEFAULT sy-datum.
*----
START OF SELECTION
*----
START-OF-SELECTION.
PERFORM getallfiles USING path.
BREAK-POINT.
*----
show date files
WRITE 😕 '----
FILES OF DATE ' , mydate.
LOOP AT allfile WHERE mod_date = mydate.
IF allfile-type CS 'file'.
WRITE 😕 allfile-name.
ENDIF.
ENDLOOP.
*----
show all files
SKIP.
SKIP.
WRITE 😕 '----
ALL FILES & DIRECTORIES'.
LOOP AT allfile .
WRITE 😕 allfile-name .
ENDLOOP.
*----
FORM
*----
FORM getallfiles USING mypath .
REFRESH allfile.
CLEAR allfile.
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 mypath
ID 'FILE' FIELD a_generic_name
ID 'ERRNO' FIELD file-errno
ID 'ERRMSG' FIELD file-errmsg.
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 = 1.
EXIT.
ENDIF.
PERFORM p6_to_date_time_tz(rstr0400) USING file-mtime
file-mod_time
file-mod_date.
allfile = file.
APPEND allfile.
ENDDO.
ENDFORM. "GETALLFILES
*----
FORM
*----
FORM p6_to_date_time_tz USING gmtime
asc_time
asc_date.
DATA: opcode TYPE x,
unique, not_found,
timestamp TYPE i,
date TYPE d,
time TYPE t,
tz LIKE sy-zonlo,
timestring(10),
abapstamp(14),
abaptstamp TYPE timestamp.
timestamp = gmtime.
IF sy-zonlo = space.
Der Benutzer hat keine Zeitzone gepflegt: nehme lokale des App. Srv.
CALL FUNCTION 'TZON_GET_OS_TIMEZONE'
IMPORTING
ef_timezone = tz
ef_not_unique = unique
ef_not_found = not_found.
IF unique = 'X' OR not_found = 'X'. .
tz = sy-tzone.
CONCATENATE 'UTC+' tz INTO tz.
ENDIF.
ELSE.
tz = sy-zonlo.
ENDIF.
wandle den Timestamp in ABAP Format um und lass den ABAP konvertieren
opcode = 3.
CALL 'RstrDateConv'
ID 'OPCODE' FIELD opcode
ID 'TIMESTAMP' FIELD timestamp
ID 'ABAPSTAMP' FIELD abapstamp.
abaptstamp = abapstamp.
CONVERT TIME STAMP abaptstamp TIME ZONE tz INTO DATE date
TIME time.
IF sy-subrc <> 0.
date = abapstamp(8).
time = abapstamp+8.
ENDIF.
WRITE: time(2) TO timestring(2),
':' TO timestring+2(1),
time2(2) TO timestring3(2),
':' TO timestring+5(1),
time4(2) TO timestring6(2).
MOVE timestring TO asc_time.
MOVE date TO asc_date.
ENDFORM. "P6_TO_DATE_TIME_TZ
*
I hope it helps.
Regards,
Amit M.