In case you are OK to use a bit of C functions within RPGLE then the following is the link to retrieve the list:
If restricted to using RPGLE and CLLE then you can do it as follows
– Listfile has to be created with the CRTPF command without a DDS, the length of the record depends on the maximum possible length of the filename in the IFS dir.
– QSH needs to be installed.
On execution of this command, which is nothing but an output redirection, the file listfile is populated with the filenames of the files in IFS.
DCL VAR(&LSCOMMAND) TYPE(*CHAR)
DCL VAR(&LIBRARY) TYPE(*CHAR) LEN(10)
CHGVAR VAR(&LSCOMMAND) VALUE(‘LS /dir1/dir2/ > +
/QSYS.LIB/’ *TCAT &LIBRARY *TCAT +
USER FEEDBACK TO THIS TIP
If you do not have QSHELL installed, then you probably do have FTP installed. Then you still can see what is in the IFS… use FTP to your local box using the reserved loopback IP address 127.0.0.1
Here’s how to do it:
The FTP command “DIR” will generate a file your RPG programs can read.
Code: Your CL source should perform a CHGCURLIB &LIB so you know where the file will be put when generated.
You then OPEN an FTP connection using FTP source. The IP address that you open is FTP RMTSYS(‘127.0.0.1’) and your FTP source should look like:
DIR /dir1 (DISK
You can then write an RPG program to read the disk file created in your &LIB called DIROUTPUT. This is a more portable solution and the output is great for an RPG subfile, which lets users pick which uploaded file they wish to process