The goal of this exercise is to read and store an input file into a table then validate certain fields within the input and output any error records. The input file that needs to be stored is 285 records. The problem is that each record is different, with it's own copybook, so I don't know how to load it to a table to where I could search each 10, 20, or 32 record for a certain field. Here's a sample of the input file FYI... Not sure if my current code would be needed at this point as there's not much in it except for a READ statement.

10A 018517          2005062520060625                                    
20A 018517000861038                                                     
32A 018517                            79372                             
60A 0185172020                                             6          4 
94A 018517     080 1                                                    
10A 027721          2005082520060825                                    
20A 027721000187062                                                     
32A 027721                            05038                             
60A 0277212003                                             6          4 
94A 027721     090 1                                                    
....

I was able to load the file into the table, but now my dilemma is how to search each different record field in the table to validate? i.e. how can I validate that the zip code in record 32 is numeric?

I know I could read into the copybook, but I don't how, or if its even possible, to read a file into multiple copybooks and then store it all in a table.. if that makes sense.

Any advice on where to go from here would be greatly appreciated!

有帮助吗?

解决方案

A couple of question

  1. Why do you have to move the values to a Table instead of doing the Tests while reading in the file ???.
  2. 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

  1. Read the file into the Table
  2. Include the Copybooks in working Storage
  3. 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

  1. Only store the related records in the table
  2. 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

其他提示

Looking back at a copybook you showed previously, it had an 01 on it. This can convolute things for your task. Never mind.

Once you have all the records stored in your table, you can look at each item in sequence, paying attention only to the first two bytes of each entry, identify the entry by the record-type and MOVE the entry to the appropriate 01 for that record-type. The use the copybook-names for all your validation/reporting.

Without the 01s on the copybooks, you could have used the copybooks in a REDEFINES of the table entry and just use the appropriate copybook, by the same method as above, without having to do the MOVE.

There is a "more advanced" way to do it, but it'll probably butt into what you are learning at the moment. Make a note to yourself to ask in a couple of months' time, when you are more at ease with COBOL.

The task you have is just an exercise. It is unlikely that you'll ever store a file like that in a table like that. It is to get you used to file-processing and table-processing.

File-processing and table-processing are very common things, so get good at them through practice. Try to work through your course notes and the manuals first. Then tutor/colleagues. You'll find the learning easier than just coming here for answers. If you do get stuck, you are of course welcome to ask, but get stuck first please :-)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top