IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to find the number of files used in a program?


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Kayathri K

New User


Joined: 25 Sep 2013
Posts: 4
Location: India

PostPosted: Thu Feb 27, 2014 5:44 pm
Reply with quote

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.. icon_wink.gif )? "

Is there any specific command to know that?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Feb 27, 2014 6:16 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 27, 2014 6:21 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Feb 27, 2014 6:36 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 27, 2014 7:25 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 27, 2014 7:47 pm
Reply with quote

Pandora,

Apologies, as I seem to have repeated your observations. icon_redface.gif
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Feb 27, 2014 8:04 pm
Reply with quote

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 icon_biggrin.gif
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Feb 27, 2014 8:41 pm
Reply with quote

Another option: count the number of "DSN=" in your JCL for the step that executes your COBOL program.
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Thu Feb 27, 2014 8:55 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 27, 2014 9:33 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Thu Feb 27, 2014 9:45 pm
Reply with quote

I have Rexx macro which does this quickly... icon_smile.gif

Also as Goodman said, yes I agree to have it looked into listings as well.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Feb 27, 2014 9:48 pm
Reply with quote

Quote:
I have Rexx macro which does this quickly...


How does that help for a interview question?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri Feb 28, 2014 12:20 am
Reply with quote

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.. icon_smile.gif
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Feb 28, 2014 1:03 am
Reply with quote

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
View user's profile Send private message
Kayathri K

New User


Joined: 25 Sep 2013
Posts: 4
Location: India

PostPosted: Fri Feb 28, 2014 12:18 pm
Reply with quote

Thanks for all your time and suggestions. I will be able to answer this question next time (provided there are no sub-programs involved icon_smile.gif )..

It was really helpful!
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri Feb 28, 2014 12:40 pm
Reply with quote

So which one the most you liked then ? icon_smile.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri Feb 28, 2014 12:41 pm
Reply with quote

Pandora,

I got your point. ....
Back to top
View user's profile Send private message
Kayathri K

New User


Joined: 25 Sep 2013
Posts: 4
Location: India

PostPosted: Fri Feb 28, 2014 3:10 pm
Reply with quote

Rohit,
I liked the simple "FIND ALL" icon_smile.gif

and ofcourse TGT.. Its useful to know about that!!
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri Feb 28, 2014 3:13 pm
Reply with quote

Good...hope it helps to get through your next round of interviews. ...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
Search our Forums:

Back to Top