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 present in a folder on application server ?

Former Member
0 Kudos

Hi,

How to get all file names present inside a folder which is on application server ? (not on my workstation !)

Like CL_GUI_FRONTEND_SERVICES~DIRECTORY_LIST_FILES, but for a SAP server.

Thanks

Mickael

2 REPLIES 2

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Hi Michael, you could use that class/method, but you just provide the full path with host name and it must be open on your network, but instead try this example program.



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/'.


call function 'RZL_READ_DIR_LOCAL'
     exporting
          name           = p_path
     tables
          file_tbl       = ifile
     exceptions
          argument_error = 1
          not_found      = 2
          others         = 3.

loop at ifile.
  format hotspot on.
  write:/ ifile-name.
  hide ifile-name.
  format hotspot off.
endloop.


at line-selection.

  concatenate p_path ifile-name into p_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.

  loop at itab.
    write:/ itab.
  endloop.

Regards,

Rich Heilman

0 Kudos

Thanks it works fine.

Note: for unicode (ECC 6.0), we have to add "ENCODING DEFAULT" with "open dataset ".

Else I found also FM " TMP_GUI_DIRECTORY_LIST_FILES "

Edited by: Mickael Huchet on Dec 21, 2007 2:59 PM