Page 1 of 1

Find Copybook of a dataset used in JCL

PostPosted: Wed Apr 16, 2014 1:21 pm
by jiteshyadav
Hi,

I have a requirement to find out the name of the copybook for a dataset used in the JCL.
The best way to do this (which I could think of) is to find the DD name and COBOL Program name from the JCL for that dataset and use DD name in COBOL program to find out the copybook. Is my approach correct/optimal?

Also, I have written Rexx code to find out the DD name & COBOL program name and it's working fine.
My concern lies in extracting the copybook name from the COBOL program as there can be multiple ways to handle files in the COBOL program.
Below are the few possibilities:
1. Copybook can be specified in FILE section under FD.
2. Or we can just give a record under FD and expand that record with COPY statement in Working Storage Section.
3. Layouts could have been REDEFINEd in the program.
4. Same file can be written with multiple record layouts for e.g. header, detail, trailer etc.

Since there is no standard way, it's hard to extract correct details and cover all the above and many others.

Any suggestions.

Re: Find Copybook of a dataset used in JCL

PostPosted: Wed Apr 16, 2014 2:59 pm
by NicC
Another way is to not have a copybook at all. I have several datasets like that because they are leaving the mainframe and going to Excel so a copybook is not required.

Re: Find Copybook of a dataset used in JCL

PostPosted: Wed Apr 16, 2014 3:14 pm
by jiteshyadav
Hi nicC,

But my requirement is to get the copybooks specifically.
Any suggestion in that direction will be helpful.

Thanks.

Re: Find Copybook of a dataset used in JCL

PostPosted: Wed Apr 16, 2014 9:35 pm
by Robert Sample
You have defined the problem. Unless you (or your site) does some research and finds a tool on the market to do what you want, you are going to be stuck writing code to cover the various cases (which will take some time) -- or you can abandon the effort as not worth the trouble. Since copy books do NOT have to be related to a file, you need to consider that in your code, too.

Re: Find Copybook of a dataset used in JCL

PostPosted: Wed Apr 16, 2014 11:39 pm
by dick scherrer
Hello,

It would indeed be difficult to identify everything using that approach.

Another approach could be to make a cross-reference of which dataset(s) are defined by which copybook(s).

Then search the production/test/personal jcl for wherever these dataseta are used. Which has the advantage of identifyiing when the datasets are used in processes that are not cobol (i.e. sort, easytrieve, etc).

Re: Find Copybook of a dataset used in JCL

PostPosted: Thu Apr 17, 2014 10:35 am
by jiteshyadav
Hi dick,

Thanks for your suggestion.
But I don't understand what do you mean below.
dick scherrer wrote:Another approach could be to make a cross-reference of which dataset(s) are defined by which copybook(s).

How to do this cross-reference? The only place where we use layout for any dataset is in the code (COBOL, Easytrieve etc.) itself.
Can you please elaborate it a bit.

Thanks.

Re: Find Copybook of a dataset used in JCL

PostPosted: Thu Apr 17, 2014 7:53 pm
by dick scherrer
Hello,

How to do this cross-reference?
I suspect this would largely be done by first determining which copybooks define files and which are for other uses.

Then take the copybooks that define files and enter the dataset names defined by each copybook. If this does not already exist to some degree, it will need to be entered.

I don't know about your organization, but the organizations I've supported had people who knew which copybooks went with which files. If this institutional knowledge does not exist, the gathering will take longer.

Re: Find Copybook of a dataset used in JCL

PostPosted: Fri Apr 18, 2014 9:58 am
by jiteshyadav
Hi Dick,

I think it's just the difference of shops then. In our shop we don't have any such reference/repository of a copybook with the file from where we can know which copybook is associated with which file.
The only place where you can look for the copybook of a file is in the COBOL program.
Based on the responses above, I think there is no full proof way to identify the copybooks for all datasets as the standards vary from shop to shop.
Any way I will be giving it a shot following the approach I specified in my first post covering maximum scenarios which I can.
At least it will be helpful in some cases if not in all.