‎2007 Sep 20 7:10 AM
Hii
Can anyone help me in finding a function module that lists all the files form the application server directory along with the craetion date and time??
I was using the function module SUBST_GET_FILE_NAME which lists all the files, but the date and time is not maintained here..I mean, the file creation date and time fields are available, but blank..I want the date and time as can be seen in AL11 when we browse for a file in a directory..
Tx
‎2007 Sep 20 7:15 AM
One FM is RZL_READ_DIR but it dont give file attributes.
You may also check these -
RZL_READ_DIR Read directories of an application server
RZL_READ_DIR_GLOBAL Read directories of an application server
RZL_READ_DIR_LOCAL Read local directory
RZL_READ_DIR_REMOTE Read Remote Directory
RZL_READ_DIR_REMOTE_SH Read Directory: Cross Host Boundary via Remote OS Mechanism
RZL_READ_FILE Read file, cross host boundary via sap adm mechanim
RZL_READ_FILE_LOCAL Read local file
RZL_READ_FILE_REMOTE Read file
RZL_READ_FILE_REMOTE_SH Read file, cross host boundary via remote-os-mechanism
Regards,
Amit
‎2007 Sep 20 7:34 AM
In Al11, there is a form 'fill_file_list' which does what you require (program: RSWATCH0)
it has a statement
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.which read everything
perhaps, you can call the same form fill_file_list in your program
‎2007 Sep 20 7:37 AM
Hi try using this
EPS_GET_DIRECTORY_LISTING Get directory listing
EPS_GET_DIRECTORY_PATH Get directory path for EPS subdirectories
EPS_GET_FILE_ATTRIBUTES
Please reward if useful.
‎2007 Sep 20 8:01 AM
Hi,
use this program or put the code in a function module if you want
i have not provided any output, so put a breakpoint at the write:/ 'end'. statement and see the contents of the file_list internal table
*&---------------------------------------------------------------------*
*& Report ZKRIS_GET_DIRECTORY_FILES_ATTR
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zkris_get_directory_files_attr.
PARAMETERS: p_dir(128) DEFAULT 'write your dir name here'.
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: sap_yes(1) VALUE 'X'
, sap_no(1) VALUE ' '
, srt(1) VALUE 'T'
, no_cs VALUE ' ' " no MUST_ContainString
, all_gen VALUE '*' " generic filename shall select all
, strlen LIKE sy-fdpos
.
DATA: BEGIN OF file_list OCCURS 100,
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_list.
DATA: BEGIN OF searchpoints OCCURS 10,
dirname TYPE name_of_dir, " name of directory.
sp_name TYPE name_of_file, " name of entry. (may end with *)
sp_cs(10) TYPE c, " ContainsString pattern for name.
END OF searchpoints.
searchpoints-dirname = p_dir.
searchpoints-sp_name = '*'.
searchpoints-sp_cs = ''.
PERFORM fill_file_list USING searchpoints-dirname
searchpoints-sp_name
searchpoints-sp_cs
.
WRITE:/ 'end'.
*&---------------------------------------------------------------------*
*& Form fill_file_list
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->A_DIR_NAME text
* -->A_GENERIC_NAME text
* -->A_MUST_CS text
*----------------------------------------------------------------------*
FORM fill_file_list USING a_dir_name a_generic_name a_must_cs.
" Routine von M. Mittelstein
******************************************************************CAS***
* Es wird eine Liste von Dateinamen in die Tabelle FILE_LIST gelesen.
*
* A_DIR_NAME ....... directory name
* A_GENERIC_NAME ... generic filename (may end with *)
* A_MUST_CS ........ a contains pattern for legal filenames OR NO_CS
*
DATA: errcnt(2) TYPE p VALUE 0.
* call 'C_DIR_READ_FINISH' " just to be sure
* id 'ERRNO' field file_list-errno
* id 'ERRMSG' field file_list-errmsg.
*
* call 'C_DIR_READ_START' id 'DIR' field a_dir_name
* id 'FILE' field a_generic_name
* id 'ERRNO' field file-errno
* id 'ERRMSG' field file-errmsg.
IF sy-subrc <> 0.
sy-subrc = 4.
EXIT.
ENDIF.
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.
file-dirname = a_dir_name.
MOVE sy-subrc TO file-subrc.
CASE sy-subrc.
WHEN 0.
CLEAR: file-errno, file-errmsg.
CASE file-type(1).
WHEN 'F'. " normal file.
PERFORM filename_useable USING file-name file-useable.
WHEN 'f'. " normal file.
PERFORM filename_useable USING file-name file-useable.
WHEN OTHERS. " directory, device, fifo, socket,...
MOVE sap_no TO file-useable.
ENDCASE.
IF file-len = 0.
MOVE sap_no TO file-useable.
ENDIF.
WHEN 1. " end of directory
EXIT.
WHEN 4. " filename too long
MOVE sap_no TO file-useable.
WHEN OTHERS.
ADD 1 TO errcnt.
IF errcnt > 90.
EXIT.
ENDIF.
IF sy-subrc = 5.
MOVE: '???' TO file-type,
'???' TO file-owner,
'???' TO file-mode.
ELSE.
* ULINE.
* WRITE: / 'C_DIR_READ_NEXT', 'SUBRC', SY-SUBRC.
ENDIF.
MOVE sap_no TO file-useable.
ENDCASE.
PERFORM p6_to_date_time_tz(rstr0400) USING file-mtime
file-mod_time
file-mod_date.
* * Does the filename contains the requested pattern?
* * Then store it, else forget it.
IF a_must_cs = no_cs.
MOVE-CORRESPONDING file TO file_list.
APPEND file_list.
ELSE.
IF file-name CS a_must_cs.
MOVE-CORRESPONDING file TO file_list.
APPEND file_list.
ENDIF.
ENDIF.
ENDDO.
CALL 'C_DIR_READ_FINISH'
ID 'ERRNO' FIELD file_list-errno
ID 'ERRMSG' FIELD file_list-errmsg.
IF sy-subrc <> 0.
WRITE: / 'C_DIR_READ_FINISH', 'SUBRC', sy-subrc.
ENDIF.
IF srt = 'T'.
SORT file_list BY mtime DESCENDING name ASCENDING.
ELSE.
SORT file_list BY name ASCENDING mtime DESCENDING.
ENDIF.
sy-subrc = 0.
ENDFORM. "FILL_FILE_LIST
*&---------------------------------------------------------------------*
*& Form filename_useable
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->A_NAME text
* -->A_USEABLE text
*----------------------------------------------------------------------*
FORM filename_useable USING a_name a_useable.
*----================------------------------
DATA l_name(75).
l_name = a_name.
IF l_name(4) = 'core'.
a_useable = sap_no.
ELSE.
a_useable = sap_yes.
ENDIF.
ENDFORM. "FILENAME_USEABLE
‎2015 Apr 10 8:18 PM