06-29-2009 5:05 PM
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
06-29-2009 5:12 PM
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
06-29-2009 5:26 PM
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.
06-29-2009 5:31 PM
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
06-30-2009 9:27 PM
07-30-2009 4:17 PM
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