Copybook To handle different fields



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Copybook To handle different fields

Postby Manjucan » Mon Jul 15, 2019 4:44 pm

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?
Manjucan
 
Posts: 9
Joined: Thu Feb 07, 2019 10:09 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Copybook To handle different fields

Postby Robert Sample » Mon Jul 15, 2019 6:08 pm

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.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Copybook To handle different fields

Postby chaat » Fri Jul 19, 2019 3:02 am

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.
chaat
 
Posts: 27
Joined: Sun Aug 16, 2009 11:07 pm
Location: St. Cloud, Minnesota
Has thanked: 0 time
Been thanked: 1 time

Re: Copybook To handle different fields

Postby Robert Sample » Fri Jul 19, 2019 3:18 am

As long as each 01 has the same length, you can have multiple 01 levels in the FD for a fixed block.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post