100 pts.
 RCVF In CL
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.

Software/Hardware used:
ASKED: February 20, 2008  3:23 PM
UPDATED: April 13, 2009  4:38 AM

Answer Wiki:
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. Regards, Vibhav ------------------------------------------------------------------------------------------------------ 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
Last Wiki Answer Submitted:  April 13, 2009  4:38 am  by  Vibhav   45 pts.
All Answer Wiki Contributors:  Vibhav   45 pts. , FCARPENTER   200 pts. , bvining   6,055 pts. , ITKE   16,755 pts. , Ashnirody   100 pts. , Gilly400   23,625 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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

 7,175 pts.

 

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

 23,625 pts.

 

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.

 6,055 pts.

 

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