A couple of question
- Why do you have to move the values to a Table instead of doing the Tests while reading in the file ???.
- Does the assignment specifically state that you must read every record into a Table before doing any tests ??? or do you just need to store all the Related-Records in a table and print them all out if one of them has an error ???. It would be better to store as little as possible in the table.
If you need to store the whole file in a table, Basically you could
- Read the file into the Table
- Include the Copybooks in working Storage
When you want to Test a Table-Entry check the record-type and move the table entry to the appropriate copybook.
01 File-Records. 03 filler occurs 285. 05 Table-Entry Pic X(80). 05 Filler redefines Table-Entry Pic XX. 88 Record-Type-10 value "10". .... 88 Record-Type-94 value "94". Evaluate true when Record-Type-10(table-index) Move Table-Entry(table-index) to Copybook-10 ...Whatever processing is needed... ... when Record-Type-94(table-index) Move Table-Entry(table-index) to Copybook-94 .... end-evaluate
I would prefer to
- Only store the related records in the table
- Test the values as you read them in (or store for checking at the when the complete record-group has been read in).
in which case logic like the following could be used
Evaluate true
when Record-Type-10
if group-in-error
...write all the table-entries to the Error-File...
end-if
set group-in-error-off to true
move 1 to table-index
... Record-Type-10 tests ...
when group-in-error
continue
when Record-Type-20
... Record-Type-20 tests ...
end-Evaluate
move Intput-record to Table-entry(table-index)
Add 1 to table-index