View previous topic :: View next topic
|
Author |
Message |
Kayathri K
New User
Joined: 25 Sep 2013 Posts: 4 Location: India
|
|
|
|
Hi,
I was asked this question in an interview:
"How to find the number of files used in a COBOL program (without manually counting ofcourse.. )? "
Is there any specific command to know that? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Use TSO/ISPF and issue primary command FIND ALL ' SELECT' -- which would include any sort file defined. FIND ALL ' FD ' would exclude sort files.
The question is pretty bogus -- the usual way would be to manually review the code for SELECT statements. And nobody cares about how many files are used in a COBOL program, typically, as the concern is which files and are they input, output, or both? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Look at the storage allocation towards the end of the compile listing (assuming you've included it) and look at the last pair. The number of files will be "obvious". This will exclude files used by ACCEPT and DISPLAY, but that's probably OK. If you need to know they are used, there are some easy ways, including listing the VERBs. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Also If the sub programs reads file(s)- The job might have some extra files and possible that the Main program might not be having any. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
If the MAIN program CALL's Sub-Program(s), files could be defined in the Sub-Program as EXTERNAL and the MAIN program wouldn't know anything about them. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Pandora,
Apologies, as I seem to have repeated your observations. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Quote: |
Apologies, as I seem to have repeated your observations. |
Bill,
Not an issue at all.Felt happy to see some expert thinks like me |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Another option: count the number of "DSN=" in your JCL for the step that executes your COBOL program. |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
But all of these involve manually counting, which was disallowed in the original question...
They are probably fishing for something with the TGT and the number of FCBs indexed there. At the bottom of one of my listings, it shows the "Number of FCB'S" is at offset x64 in the TGT table.
And since we're in the world of guessing what they meant, files "a program uses" would not include any subroutine EXTERNAL files, since they aren't used by the program in question. However, something like an IMS GSAM file would be, and would not have an FCB.
To me, the tricky part would be dynamically allocated files. They could use the same DDNAME, but open hundreds of different files in the same run.
Hopefully, this is just a "let's see how they think" kind of question, and not one with a single answer that must be matched by a candidate. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
My suggestion only involves reading, not counting. And the ability to recognise the "last", I suppose.
Unless you have a convenient dump to look at, how are you going to find the TGT value? OK, you can browse the loadlibrary, look for the TGT eycatcher and.... count... you'll get the same value by just the simple reading on the listing I suggested.
I don't see that "used in a COBOL program" should be necessarily be concerned with files used in a different COBOL program.
Dynamic allocation would make things tricky, but shouldn't preclude a simple answer for the number of static files used in an actual single COBOL program, which I think we can assume is what is being sought... |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
I have Rexx macro which does this quickly...
Also as Goodman said, yes I agree to have it looked into listings as well. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Quote: |
I have Rexx macro which does this quickly... |
How does that help for a interview question? |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
It does, as they might feel she could create it for the project and she might get the interview cleared by that and it does work in most of the interviews. However, I am sure when you list all of the above (except compile listing ) interviewer would say "this is all we do but need to know any other way to do this" and if you say "I don't know" then you might be out of the quiz and hence one time Rexx macro would do what they asks for could be another answer to get it hired.. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Rohit,
You did not get me..
In an interview it is all about how do you apply your thoughts or exhibit of knowledge
For ex.When Someone asks me how do solve S0C7 I wouldn't say I will fix and restart
I will say how to identify the error statement , how to identify errored Input ....
Similarly saying "I have a rexx macro which does this quickly" wouldn't help TS or others
Rather explain what is done in the macro or explain how it could be achieved in Rexx ( Having Copyrights and Intellectual rights in mind) |
|
Back to top |
|
|
Kayathri K
New User
Joined: 25 Sep 2013 Posts: 4 Location: India
|
|
|
|
Thanks for all your time and suggestions. I will be able to answer this question next time (provided there are no sub-programs involved )..
It was really helpful! |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
So which one the most you liked then ? |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
Pandora,
I got your point. .... |
|
Back to top |
|
|
Kayathri K
New User
Joined: 25 Sep 2013 Posts: 4 Location: India
|
|
|
|
Rohit,
I liked the simple "FIND ALL"
and ofcourse TGT.. Its useful to know about that!! |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
Good...hope it helps to get through your next round of interviews. ... |
|
Back to top |
|
|
|