PDA

View Full Version : Reading an IFS file with an unknown file name



Guest.Visitor
12-13-2002, 01:43 PM
Vicki, My V5R2 lists an API by the name of QHFOPNDR, here is a summary of it's capabilities: The Open Directory (QHFOPNDR) API opens the specified directory so its directory entries can be read. At open time, the directory pointer points to the first entry in the directory. As directory entries are read using the Read Directory Entries (QHFRDDR) API, the directory pointer advances so that the next entries will be read during future read operations. Bill Vicki Jones wrote: > We need to create a CL program that would pick up several files from > an IFS folder and put them into physical files on the AS/400. > Normally, I would use CPYFRMIMPF command but the problem is that each > time the program runs, the file names are going to have a different > suffix so we can't specify a full name of the file on a CL command. > Example would be we would have DSPR001, ARTR001, APTR001 one time, > next time it is going to be DSPR002, ARTR002, APTR002 I was wondering > if there is a way to either get a list of the files in a folder or > try to read any file that starts with a certain string sequece? Or > does anybody have even a better solution? Thanks in advance! Vicki

Guest.Visitor
12-13-2002, 04:34 PM
You can use the ls command from Qshell to list a directory to a physical file, and read the file in a CL. See the code below for an example. <hr width=50 align=left>Code ('http://www.mcpressonline.com/mc/showcode@@.6ae52e24/1')

Guest.Visitor
12-16-2002, 08:34 AM
Thank you for the info, Bill!

Guest.Visitor
12-16-2002, 08:37 AM
That sounds great. Thank you!

Guest.Visitor
01-20-2003, 05:02 AM
Hi, We need to create a CL program that would pick up several files from an IFS folder and put them into physical files on the AS/400. Normally, I would use CPYFRMIMPF command but the problem is that each time the program runs, the file names are going to have a different suffix so we can't specify a full name of the file on a CL command. Example would be we would have DSPR001, ARTR001, APTR001 one time, next time it is going to be DSPR002, ARTR002, APTR002 I was wondering if there is a way to either get a list of the files in a folder or try to read any file that starts with a certain string sequece? Or does anybody have even a better solution? Thanks in advance! Vicki

Guest.Visitor
01-20-2003, 05:02 AM
I use Unix APIs opendir, readdir,closedir. I had to write this in RPGLE because of the pointers and other data types.