If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
You don’t tell us what version your system is at, so it’s hard to know the right answer. If you’re at v6.1 or later, review Reading a file twice in CL before anything else.
If you’re at V5R4 or earlier, then a single CL program cannot read the same file again after reaching end-of-file. That’s simply the way it works. CL is a control language not a database processing language.
You can work around it it two general ways.
You can split your program into two programs — one for an outer control structure and the other for the file-processing portion. The outer control code would call the inner program twice (or as many times as needed.)
Or you can use RTVMBRD or a similar function to retrieve the number of records in the file before you start to read it. As you read records, keep count of them and compare your count to the number of records in the file’s member. Stop reading after you have counted as many are in the file. If you try to read one more than that, end-of-file will be reached and you can’t go beyond that. But if you stop just before end-of-file is signaled, you can reposition back to *START and read again.
You don’t tell us what version your system is at, so it’s hard to know the right answer. If you’re at v6.1 or later, review Reading a file twice in CL before anything else.
If you’re at V5R4 or earlier, then a single CL program cannot read the same file again after reaching end-of-file. That’s simply the way it works. CL is a control language not a database processing language.
You can work around it it two general ways.
You can split your program into two programs — one for an outer control structure and the other for the file-processing portion. The outer control code would call the inner program twice (or as many times as needed.)
Or you can use RTVMBRD or a similar function to retrieve the number of records in the file before you start to read it. As you read records, keep count of them and compare your count to the number of records in the file’s member. Stop reading after you have counted as many are in the file. If you try to read one more than that, end-of-file will be reached and you can’t go beyond that. But if you stop just before end-of-file is signaled, you can reposition back to *START and read again.
Tom