Page 1 of 1

Copybook To handle different fields

PostPosted: Mon Jul 15, 2019 4:44 pm
by Manjucan
Hi all,

We have a scenario where the same program is invoked by 2 different jobs -A and B.

When the program is called by Job A , the output file will have 5 fields and when the call is made by program B ,the output file will have 6 fields (one extra field at the beginning of the previous 5 fields).

How will we handle the scenario in output copybook?

Re: Copybook To handle different fields

PostPosted: Mon Jul 15, 2019 6:08 pm
by Robert Sample
First, you don't handle such a condition in a copy book -- copy books are for SOURCE code and are used whenever the same code is reused between programs.

Second, assuming that what you REALLY mean is how to handle this situation -- pass from program A and program B a value that indicates which program is doing the call, so the subprogram can then write out the correct data based upon which program called it. You have two different 01 levels in the FD, each with one of the file layouts. You have two WRITE statements, one for each program call, which reference the different FD 01 levels. No copy book needed and hence no copy book changes required.

Re: Copybook To handle different fields

PostPosted: Fri Jul 19, 2019 3:02 am
by chaat
Question, will multiple 01 levels of different lengths work correctly if the file is defined as fixed blocked. It would work with variable length that I'm sure of.

Re: Copybook To handle different fields

PostPosted: Fri Jul 19, 2019 3:18 am
by Robert Sample
As long as each 01 has the same length, you can have multiple 01 levels in the FD for a fixed block.