Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: How to find the number of files used in a program?
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: 7912
Location: Bellevue, IA

PostPosted: Thu Feb 27, 2014 6:16 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Feb 27, 2014 6:21 pm    Post subject: Reply to: How to find the number of files used in a program?
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

Moderator


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

PostPosted: Thu Feb 27, 2014 6:36 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 27, 2014 7:25 pm    Post subject: Reply to: How to find the number of files used in a program?
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 27, 2014 7:47 pm    Post subject: Reply to: How to find the number of files used in a program?
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

Moderator


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

PostPosted: Thu Feb 27, 2014 8:04 pm    Post subject:
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: 1238
Location: Richfield, MN, USA

PostPosted: Thu Feb 27, 2014 8:41 pm    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Feb 27, 2014 9:33 pm    Post subject: Reply to: How to find the number of files used in a program?
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Thu Feb 27, 2014 9:45 pm    Post subject:
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

Moderator


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

PostPosted: Thu Feb 27, 2014 9:48 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Fri Feb 28, 2014 12:20 am    Post subject:
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

Moderator


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

PostPosted: Fri Feb 28, 2014 1:03 am    Post subject:
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    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Fri Feb 28, 2014 12:40 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Fri Feb 28, 2014 12:41 pm    Post subject:
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    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Fri Feb 28, 2014 3:13 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 3 Tue Dec 06, 2016 8:30 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us