Display 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:

For files and tables, the record contains the following additional fields:

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:
  1. All server 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.
  2. 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).
  3. The use of the local data area is not stored.
  4. 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
Related reference
Display Program References (DSPPGMREF) command
Element definition (ELEM)