Displaying objects used by programs
You can use the Display Program References (DSPPGMREF) command to determine which tables, data areas, and other programs are used by a program or SQL package. This information is only available for SQL packages and compiled programs and can be displayed, printed, or written to a database output file.
When a program or package is created, the information about certain objects used in the program or package is stored. This information is then available for use with the Display Program References (DSPPGMREF) command. Information retrieved can include:
- The name of the program or package and its text description
- The name of the library or collection containing the program or package
- The number of objects referred to by the program package
- The qualified name of the system object
- The information retrieval dates
- The object type of the referenced object
For files and tables, the record contains the following additional fields:
- The name of the file or table in the program or package (possibly different from the system object name if an override operation was in effect when the program or package was created)
Any overrides apply only on the application requester (AR).
- The program or package use of the file or table (input, output, update, unspecified, or a combination of these four)
- The number of record formats referenced, if any
- The name of the record format used by the file or table and its record format level identifier
- The number of fields referenced for each format
Before the objects can be shown in a program, the user must have *USE authority for the program. Also, of the libraries specified by the library qualifier, only the libraries for which the user has read authority are searched for the programs.
The following table shows the objects for which the high-level languages and utilities save information.
Table 1. How high-level languages save information about objects Language Files Programs Data areas See note CL Yes Yes Yes 1 COBOL/400® Language Yes Yes No 2 PL/I Yes Yes N/A 2 RPG/400® Language Yes No Yes 3 DB2® UDB SQL Yes N/A N/A 4 Notes:
- All commands that refer to files, programs, or data areas specify in the command definition that the information should be stored when the command is compiled in a CL program. If a variable is used, the name of the variable is used as the object name (for example, &FILE). If an expression is used, the name of the object is stored as *EXPR. User-defined commands can also store the information for files, programs, or data areas specified on the commands. See the description of the FILE, PGM, and DTAARA parameters on the PARM or ELEM command statements.
- The program name is stored only when a literal is used for the program name (this is a static call, for example, CALL 'PGM1'), not when a COBOL/400 identifier is used for the program name (this is a dynamic call, for example, CALL PGM1).
- The use of the local data area is not stored.
- Information about SQL packages.
The stored file information contains an entry (a number) for the type of use. In the database file output of the Display Program References (DSPPGMREF) command (built when using the OUTFILE parameter), this entry is a representation of one or more codes listed here. There can only be one entry per object, so combinations are used. For example, a file coded as a 7 would be used for input, output, and update.
- Code
- Meaning
- 1
- Input
- 2
- Output
- 3
- Input and Output
- 4
- Update
- 8
- Unspecified
- Example: Displaying program reference
To see what objects are used by an application requester (AR) program, you can enter a command as follows.
Parent topic:
Administration
Related reference
Display Program References (DSPPGMREF) command
Element definition (ELEM)