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,
<a href=”http://www.brucevining.com/”>Bruce Vining Services</a>