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

Application layer

Former Member
0 Likes
641

Any Professional plz ans this query :

how can we read all the files from a specific directory on application server

say for example :

"c:\usr\sap\id3\dvebmgs00\data" under this directory there 3 files

1. file1.txt

2. file2.txt

3. file3.txt

Now i have to read all the file names into my program how can i do that.

Plzzzz give me the best answer.

Thanks in Advance .

5 REPLIES 5
Read only

Simha_
Product and Topic Expert
Product and Topic Expert
0 Likes
606

Hi,

Please check this threads for solution.

Cheers,

SImha.

Read only

Former Member
0 Likes
606

hi,

use transaction <b>AL11</b>

<b>pls reward if helpful</b>.

Read only

Former Member
0 Likes
606

Use

Transfer statement to transfer data from appl server to internal table.

reward if helpful.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
606

Try something like this.



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.
  perform read_file.
endloop.

*---------------------------------------------------------------------*
*       FORM read_file                                                *
*---------------------------------------------------------------------*
form read_file.

  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.

endform.

Regards,

RIch Heilman

Read only

Former Member
0 Likes
606

Hi

Use<b> AL11</b> Transaction to see the files on Application server.

or use the

OPENDATASET...

READ DATASET...

CLOSE DATASET...

to move the files to an internal table and to display

or use

<b>CG3Y</b> Transaction to downlaod all the fiels to presentation server from application server

Regards

Anji