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: 

Read Files from Directory on Application server

sastry_gunturi
Active Participant
0 Kudos

Is there any Function module/ Classes available for reading all files in directory on the application server. I tried these FM's but it did'nt work

RZL_READ_DIR_LOCAL & EPS_GET_DIRECTORY_LISTING

5 REPLIES 5

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Karthik,

If you DONOT want to waste your time writing READ DATASET, then you can use the combination of EPS_GET_DIRECTORY_LISTING & EPS_OPEN_OUTPUT_FILE / EPS_OPEN_INPUT_FILE.

Algo for this:

1. Call the FM EPS_GET_DIRECTORY_LISTING & get the list of all the files in the table DIR_LIST.

2. Loop at DIR_LIST & then call the FM EPS_OPEN_OUTPUT_FILE / EPS_OPEN_INPUT_FILE.

FYI, the FM EPS_GET_DIRECTORY_LISTING only lists the filenames & does not read the file.

BR,

Suhas

0 Kudos

Suhas,

Thanks for the reply. I have already tested EPS_GET_DIRECTORY_LISTING it is not working for me. Let me be a bit clear... i am looking for FM/Classes which can list all files in the directory on application server.... I know that i have to read them individually using READ DATASET......

Thanks

Karthik.

0 Kudos

Hello,

What value are you passing to the import param: DIR_NAME. It should be the same name as it appears on AL11.

BR,

Suhas

0 Kudos

Hi,

have a look at this thread:

Best regards.

Former Member
0 Kudos

Hi, to get the list of all files in a directory on application server, use the following code:


    DATA:  unixcommand(300) TYPE c,
         files              TYPE STANDARD TABLE OF localfile,
         wa_file         TYPE localfile.

*   Get all files under the working directory
    CONCATENATE 'ls' p_dir INTO unixcommand  SEPARATED BY space.

*   Call unix command
    CALL 'SYSTEM' ID 'COMMAND' FIELD  unixcommand
                   ID 'TAB'            FIELD files[].
    LOOP AT files INTO wa_file.
.........
   ENDLOOP.

After executing Unix command, internal table files[] contains all file names in the directory.

Hope it helps.

Irina