Question

  Asked: Feb 20 2008   3:23 PM GMT
  Asked by: Ashnirody


RCVF In CL


CLP, POSDBF, OPNQRYF, OVRDBF, RCVF

I am using nested RCVF to read PF's in a CL program. The second iteration of the inner loop does not happen because the pointer is set to end of file. How do I reset the pointer to start at the begining? I have tried OVRDBF, OPNQRYF, POSDBF and deleting and recreating the PF.

Thank you for your help.

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



Hi,

I don't think this is going to work unless you use a separate CL for each "nesting level". According to the RCVF information from the CL manuals :-

Only one record format, of those specified in the DCLF command, can be specified in each RCVF command. If the file has not been opened by a previous RCVF, SNDRCVF, or SNDF command, it is opened by this command. If the file has been previously closed due to an end-of-file condition on a previous RCVF command, an error occurs.

So, it looks like once you've hit an end-of-file situation the CL closes the file and won't allow any further reads. IF you use another CL for your nesting level, then every time the CL is called it will open the file so you can process the records until you reach end of file, then return to the previous nesting level.

I know this isn't an ideal solution, but unfortunately CL still has it's limitations.

Hope this helps,

Martin Gilbert.

--------------------------------------------------------------------------------------------------------

FYI - In V6R1 CL supports a CLOSE command which will close a file. The next CL RCVF will cause the file to be re-opened, allowing you to process the file again without having to introduce a second (nested) program (as you have to do in releases prior to V6R1). The command documentation is here.

Bruce Vining
http://www.brucevining.com/
  • AddThis Social Bookmark Button

Browse more Questions and Answers on AS/400.

Looking for relevant AS/400 Whitepapers? Visit the Search400.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

BigKat  |   Feb 21 2008  2:33PM GMT

Your question doesn’t say if you tried closing and re-opening (OPNDBF) the file

 

Gilly400  |   Apr 8 2008  3:18PM GMT

Unfortunately the OPNDBF command doesn’t seem to re-open a file once it’s closed.

 

Bvining  |   Apr 9 2008  2:17PM GMT

Nothing is going to reopen the file within the CL program getting end-of-file except the CLOSE and subsequent RCVF I mentioned earlier (and of course exiting the CL program and recalling it). CLOSE however is a V6R1 enhancement.

 

Ashnirody  |   Apr 9 2008  6:54PM GMT

I had to settle for moving the inner nested loop to another CL program. Ending this program and calling it again resets the pointer in the file. It is not an elegant solution but it works. Thank you all or your suggestions.

Ash