Hi,
In case you are OK to use a bit of C functions within RPGLE then the following is the link to retrieve the list:
http://www.scottklement.com/rpg/ifs.html
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)
LEN(200)
DCL VAR(&LIBRARY) TYPE(*CHAR) LEN(10)
CHGVAR VAR(&LSCOMMAND) VALUE('LS /dir1/dir2/ > +
/QSYS.LIB/' *TCAT &LIBRARY *TCAT +
'.LIB/listfile.FILE/listfile.MBR')
QSH CMD(&LSCOMMAND)
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:
user password
DIR /dir1 (DISK
CLOSE
QUIT
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
:
Last Wiki Answer Submitted: March 30, 2009 4:46 am by Dreamz1974515 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
Thanks!