hi Ron,

OPNDBF, CLOF and POSDBF don't work directly on CL files. They don't open, close or position CL files. What they *do*, however, is work on a "shared open". You open a file in the background (outside of your CL program, or any other program for that matter) and then you can share the open access path via the OVRDBF SHARE(*YES), so that your program and that background open file share the same path to the file. This is primarily to improve performance (anyone opening the file again doesn't have to create an open data path, so the open operation is much faster) but can also be used for positioning/querying the file in the background (and since you're sharing the same path, it positions your program to. This is how OPNQRYF works, for example.)

In CL, a file is opened the first time you call RCVF for it, and it's close when a CPF message (usually CPF0864=end of file) is received. Once it has been closed, you cannot reopen it. That's a known limitation of CL. Using OPNDBF/CLOF/POSDBF doesn't really help with this, since you can't share an open data path if you can't open the file!

So... you really have 3 options:

a) Replace the CL with an HLL. (RPG, Cobol, Java, C, C++, PHP etc)

b) Have a CL "sub-program" that processes the spooled file. Let that program end and call it again for each file you want to process. Since you let the routine end, the file will be closed and re-opened.

c) Instead of CPYSPLF to a PF, use the QShell 'catsplf' and 'dataq' commands to write the spooled file to a data queue. Process the data queue instead of a file.

Ron Hudson wrote:

I have a CL program which does a WRKSPLF to an outfile, then copies the outfile to a PF.

The CL loops thru each record of the first PF, and copies the splf to a second PF and reads thru this second splf looking for a string. At EOF on the second PF, or when the string is found, I want to process the next record in the first PF.

When I find the string:

if I exit the loop, then attempt to copy the next splf to the second PF, I get an error message the file is locked, even though I've done a CLOF on the second PF.

if I continue reading to EOF, I can copy the next splf to the second PF, but I'm stilled positioned at the EOF. POSDBF is not positioning to the beginnign of the file.

Is there any way around this situation.

I've searched the archives, found where this has been posted before but not a solution. I do see reference to Scott having an explanation to this but I cannot find his explanation.



With Windows Live, you can organize, edit, and share your photos.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].