Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

List of files in the applicatiion server

Former Member
0 Kudos

Hi,

The FM F4_DXFILENAME_TOPRECURSION

provides a pop-up and you need to manually select the file in the pop-up. Is there any FM apart from EPS_GET_DIRECTORY_LISTING that will return an internal table as I need the date and timestamp to queue and sort the files based on time.

Looking forward to your inputs.

cheers

Aveek

3 REPLIES 3

Former Member
0 Kudos

Hi aveek,

I don't think there is any direct FM

which will server your purpose.

Even AL11 (standard sap program)

uses this kind of logic to

get the TIME STAMP.

*----


1. Independent form.

2. I have created one independent form

which does this.

3. we need to just provide the path.

4. just copy paste this code in new program.

On selection screen provide the path

and it returns the files with TIME STAMP.

5.

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

*

regards,

amit m.

former_member188685
Active Contributor
0 Kudos

Hi Aveek,

REPORT ZTEST.

Data: unixcom like   rlgrap-filename.
data: begin of tabl occurs 500,
        line(400),
      end of tabl.

data: lines type i.
unixcom = 'ls -al'.
call 'SYSTEM' id 'COMMAND' field unixcom
                id 'TAB'     field tabl[].

  describe table tabl lines lines.
  loop at tabl.
    write:/01 tabl-line.
  endloop.
  skip 2.
  if lines = 0.
    write:/ 'NO Occurances were found'.
  endif.

"this will give all files , directories with time,and date.

Regards

vijay

Former Member
0 Kudos

Hi,

See this post to get solution:

Regards,

Prema