45 pts.
 WRKLNK on iSeries – HOW CAN I LIST THE STMF FILES UNDER A DIRECTORY
How can I list or retrieve in a cl program the STMF files under a specific directory? Urgent reply requested. I am running a cl program that run use a software package that runs decryption on a group of stmf data with variable name. I need to retrieve the names in my cl to do further processing. Or have a way to list them to an iSeries data file.

Software/Hardware used:
ASKED: April 9, 2009  5:18 PM
UPDATED: April 13, 2009  7:37 PM

Answer Wiki:
You could try using DSPLNK. In your CL set the directory using CD (CD DIRNAME). Next use DSPLNK to list the Stream File entries out to a spoolfile. The User Data value on the spoolfile will equal DSPLNK. Now use the CPYSPLF command to retrieve the spoolfile into a data file. You can declare the data file at the top of your CL. Once the file is loaded via the copy command you can start to receive the records from the file and parse out the stream file name. ------------------------------------ In <a href="http://www.brucevining.com/Articles/Article_PDFs/IndustryStandardAPIsfortheCLProgrammer_StructuresDataTypesandErrorNotification.pdf">this article</a> is a sample program that returns the name of files found in a given directory. The directory name is a parameter to the program and in (N) of Figure 1 the CL variable &Name holds the name of a directory entry during each iteration of the DoWhile loop. I hope this helps, Bruce Vining <a href="http://www.brucevining.com/">Bruce Vining Services</a>
Last Wiki Answer Submitted:  April 10, 2009  1:54 pm  by  FCARPENTER   200 pts.
All Answer Wiki Contributors:  FCARPENTER   200 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

If you can get to the directory through the IFS you can use QSHELL commands
The command would be something like “QSH CMD(ls -l directory > qsysFile)” and then use a simple DSPPFM to view the file.
“ls -l” is the Unix command to list a directory. There are lots of Unix references on the web – This is one.
“directory” is the path to the directory you want to list
“>” send the listing to a file
“qsysFile” is the file you want to put the listing in. This should be formatted as

 "/qsys.lib/yourlib.lib/yourfile.file/yourfile.mbr"

Then to look at the directory use the command

DSPPFM     FILE(YOURLIB/YOURFILE)

Hope this helps.

Regards
Mike

 2,725 pts.