The DspPgmRef command can create an outfile of all programs in a library and what files they use but it does not excent to SQL uses.
The DspDBR will give you a list of logicals over the pf. Using any of these means using the physical.
Phil
For a quick look, DSPPGMREF will work. I've written this program/command combo that builds the program reference file for all the libraries you specifiy. Put it on the schedule to run regularly, and you have a table that is always available to answer your queries:
Command:
CMD PROMPT('Update Program References')
PARM KWD(REFLIB) TYPE(*NAME) LEN(10) PROMPT('Library +
where Ref. DB Created')
PARM KWD(LIBS) TYPE(*NAME) LEN(10) MIN(1) MAX(250) +
PROMPT('Library name')
The program behind the command:
PGM PARM(&BCLIB &LIBSTOREF)
DECLARES:
/* Lib where file exists */
DCL VAR(&BCLIB) TYPE(*CHAR) LEN(10)
/* Libs containing objects to reference(up to 30) */
DCL VAR(&LIBSTOREF) TYPE(*CHAR) LEN(2502)
/* Current list item number */
DCL VAR(&CURNBR) TYPE(*DEC) LEN(5 0)
/* Current library being processed */
DCL VAR(&CURLSTITM) TYPE(*CHAR) LEN(100)
/* Library being worked */
DCL VAR(&LIB2WORK) TYPE(*CHAR) LEN(10)
/* Work variables for display */
DCL VAR(&LISTCOUNT) TYPE(*DEC) LEN(5 0)
DCL VAR(&WORK22) TYPE(*CHAR) LEN(22)
/*Build the reference file new each time */
CLRPFM FILE(&BCLIB/PGMREFS)
/* Display in job log the number of list items being processed */
CHGVAR VAR(&LISTCOUNT) VALUE(%BIN(&LIBSTOREF 1 2))
EDTVAR CHROUT(&WORK22) NUMINP(&LISTCOUNT)
SNDPGMMSG MSG(&WORK22 |< ' Libraries in the list')
DOWHILE COND(&CURNBR *GE 0)
/* Extract list for processing */
EXTLST LIST(&LIBSTOREF) ELMLEN(10) ELEMENT(&CURLSTITM) +
CURNBR(&CURNBR)
IF COND(&CURNBR *GE 0) THEN(DO)
CHGVAR VAR(&LIB2WORK) VALUE(%SST(&CURLSTITM 1 10))
SNDPGMMSG MSG('Processing... ' || &LIB2WORK)
DSPPGMREF PGM(&LIB2WORK/*ALL) OUTPUT(*OUTFILE) +
OBJTYPE(*ALL) OUTFILE(&BCLIB/PGMREFS) +
OUTMBR(*FIRST *ADD)
ERRMSG: MONMSG MSGID(CPF3064 CPF3033 CPF3034) EXEC(SNDMSG +
MSG('Library ' || &LIB2WORK || ' failed +
for DSPPGMREF command') TOUSR(U860970))
ENDDO
ENDDO
ENDIT: ENDPGM
Once this table is defined, you can build this command/program/query combo for quick answers to your "Where is this object used" questions...
Here is the WHEREUSED command:
CMD PROMPT('Identify where object is used')
PARM KWD(OBJNAM) TYPE(*CHAR) LEN(10) MIN(1) +
CHOICE('Enter all/partial object name') +
PROMPT('Object Name')
SELECT DISTINCT
-- Columns
A.WHFNAM, A.WHLIB, A.WHPNAM, A.WHTEXT,
A.WHSNAM, A.WHFUSG, A.WHOTYP, A.WHSPKG
-- Tables
FROM PGMREFS A
-- Selected Records
WHERE WHFNAM LIKE &OBJREF
-- Sort Columns
ORDER BY A.WHLIB, A.WHPNAM, A.WHFNAM, A.WHSNAM
At our site, we no longer utilize this, because we purchase a product called X-Analysis from Databorough. It provides all the whereused/whatused functionality for IBM i based code as well as providing those answers to non-IBM i based connection to IBM i based objects (e.g. JDBC/ODBC connections from java/.net/VB code sitting on AIX/Windows servers).
I've started running a set of jobs similar to what NullFields describes on various systems. I also run jobs to create lists of all source members and lists of all program and service program modules. A few years back, I'd run them over weekends (or when I chose to repopulate the files by submitting them manually). Nowadays, systems seem to handle running the jobs every night.
It's handy being able to run simple SQL statements to locate where all copies of a source member of a given name exist or where any programs are that have a particular module bound in.
If I can get a system to do my work for me, I'm all in favor.
Tom
Roughly, you can look through source code
but you may not have all of it
You can run DSPPGMREF over all objects on the system and capture the result
(this is what X-analysis does)
You can RTV files used from queries
You could take a view on whether functionality like DFU or WRKDBF or SQL is going to alter the file
You could *know* if .NET functions et al have any access
and
You can examine journal entries - because this is what *really* causes changes - but keep doing it, because year-end and housekeeping routines have a habit of popping up unexpectedly long after you think the work is done.
Why do you need to know? - perhaps the context would help limit the task.
About three years ago Roger Stein wrote an article in SystemiNews where he published a handy utility which does what you want.
The article is probably still available in the archives.
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!
Discuss This Question: 5  Replies