Application Development and Automation 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: 
Read only

Class to Get File List from Application Server

antonio_sanseverino
Participant
0 Likes
2,897

Hi all

I've to obtain the file list of a directory from application server, I can use a FM too but It's possible the lenght of file name is upper then 40 characters so I can't use FM EPS_GET_DIRECTORY_LISTING.

Thanks

Edited by: Aristoteles92 on Apr 20, 2010 3:27 PM

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
1,401

Hello,

A few days back we had a discussion the same issue. You can use an external system command to get the "xxtra-long" file names from the app server w/o getting the sames truncated.

Both EPS_GET_DIRECTORY_LISTING & RZL_READ_DIR_LOCAL have limitations on the maximum length of the filename.

Cheers,

Suhas

Edited by: Suhas Saha on Apr 20, 2010 7:09 PM

Hi all

I've to obtain the file list of a directory from application server, I can use a FM too but It's possible the lenght of file name is upper then 40 characters so I can't use FM EPS_GET_DIRECTORY_LISTING.

Thanks

Edited by: Aristoteles92 on Apr 20, 2010 3:27 PM

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,401

Try using the function RZL_READ_DIR_LOCAL. Here is an example program using this function.

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
1,402

Hello,

A few days back we had a discussion the same issue. You can use an external system command to get the "xxtra-long" file names from the app server w/o getting the sames truncated.

Both EPS_GET_DIRECTORY_LISTING & RZL_READ_DIR_LOCAL have limitations on the maximum length of the filename.

Cheers,

Suhas

Edited by: Suhas Saha on Apr 20, 2010 7:09 PM