Let assume that I have a program TESTR but i dont know how many program is calling to TESTR program. Is there any API or System file to get this. Thank You.
Software/Hardware used:
Software
ASKED:
March 30, 2012 8:02 AM
UPDATED:
April 3, 2012 11:00 PM
A DSPPGMREF will pick up many common program accesses, but it can miss many important ones. For example, any calls through a variable name will be reported simply as a generic program reference. Those will probably be rare in in-house apps.
Any system API would run into the same problem, so there is no function that does it.
Other than that, you might rename TESTR to a new name and create a new TESTR program. The new program would simply pass the parameter list through to a call to the renamed program. The new program would also retrieve the calling program from the call stack and record it somewhere. I’d probably add a keyed user index entry with the data. The key would be used to prevent a billion entries while being called in a loop or in recurring jobs.
This might be combined with DSPPGMREF to catch unusual cases.
Tom
Brown:
Thanks for your answer. But I have been tried with DSPPGMREF but not getting. As per my understanding DSPPGMREF will give the list of called program. for example MainPgm is calling SP1, SP2 ,SP3 and so on. once you give DSPPGMREF command on MainPgm, it return the list of calling program like SP1, SP2 ,SP3. but requirement is vise versa. I need to know from where SP1, SP2 ,SP3 is calling. i should get the anser MainPgm.
Hi Tom,
Thanks for your kind answer. Actually my requirement is, i have set of object list and get to know there parent program if any. for this i am planning to submit a job in batch.
my approach will be i will make outfile for each member trough RUNQRY command then I will use SQL LIKE statement. if its return a record then i will consider as parent program. Hope my requirement is clear to you.
could you please assis for any better idea.
…it return the list of calling program like SP1, SP2 ,SP3. but requirement is vise versa.
That’s right.
But the idea is that you put the output from DSPPGMREF into an outfile. Then you run DSPPGMREF over another program, and you add its output to the same outfile. You run DSPPGMREF over all of the programs in your library.
When that is done, you have a file that lists every program that is called by all of the programs in your library.
Then you can run a query to see where TESTR shows up in the file.
In fact, you can run DSPPGMREF mylib/*ALL OUTFILE(QTEMP/MYPGMREF) to get all program references from library MYLIB all at once. Wherever TESTR is referenced by one of the programs in that library, a record will show up in QTEMP/MYPGMREF.
One command is all it takes.
Just be aware that it’s not guaranteed to have every possible reference.
There can be programs that don’t call TESTR by name. Or TESTR might be called by a menu or it might be invoked by a command, or various other kinds references might exist.
Tom