user8371676
user8371676

Reputation: 55

Increase field length in sequential file

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

Answers (1)

Bruce Martin
Bruce Martin

Reputation: 10543

The solution in this case is to add the field at the end.


The Future

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

  • Add a filler at the end - disadvantage wastes space
  • Use a VB file - VB files are less common and less transportable
  • File-Driver : do all IO in the one program isolating the Programs from the file.

Adopting any of the options means:

  • Only programs that use the new field need to be recompiled.
  • When implementing changes to the file into production, the program that creates the file needs to go in first. Programs that use the new field can go in days / weeks / months latter. This can simplify implementations. A couple of small implementations are far simpler than the one enormous big bang implementation.
  • On the mainframe it saves changing the JCL each time the file attributes change.

Add a filler at the end

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

Use variable length Records

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 file driver

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

Related Questions