100 pts.
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.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi Martin and Others:

What Martin is saying is absolutely correct that once it reaches EOF, the file will be closed in CL. However we can use a logic where after reading the last record and before it reaches EOF, we need to POSDBF to position start. We can do this by retrieving the number of records in the file and use the counter to process the file.




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

Discuss This Question: 4  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • BigKat
    Your question doesn't say if you tried closing and re-opening (OPNDBF) the file
    9,460 pointsBadges:
  • Gilly400
    Unfortunately the OPNDBF command doesn't seem to re-open a file once it's closed.
    23,730 pointsBadges:
  • bvining
    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.
    7,070 pointsBadges:
  • Ashnirody
    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
    100 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: