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