Reputation: 55
if you were to extend a field length in the sequential file, would you rather add a new field at the end of the record since increasing field length in the middle of the fixed record format cause issues?
Upvotes: 0
Views: 416
Reputation: 10543
The solution in this case is to add the field at the end.
You also need to think about the future. You do not want to have to recompile every program that uses a file each time the copybook is changed. There are several solutions
Adopting any of the options means:
Simply define the file as
01 My-Copybook
05 First-field Pic ...
....
05 Last-field Pic ...
05 Filler Pic X(60).
when it comes to add a new field, you use some of the filler at the end:
01 My-Copybook
05 First-field Pic ...
....
05 Last-field Pic ...
05 new-field pic X(10)
05 Filler Pic X(50). *> reduced to 50
You could use a VB file like
01 Largest-possible-record Pic x(500).
01 My-Copybook
05 First-field Pic ...
....
05 Last-field Pic ...
You can now expand your record upto 500 bytes.
Use a module (File-Driver) to read / write the file. All application programs would call the File-Driver to do the actual IO.
The application programs would havwe something like
05 Large-Record Pic x(1000).
05 My-Record redefines Large-Record.
10 First-field Pic ...
....
10 Last-field Pic ...
A file driver can do more than just write the file, they can add / validate Header / trailers or other file check records that application programs are not interested in.
Upvotes: 3