Display the files used by programs

Use the Display Program Reference (DSPPGMREF) command to determine which files, data areas, and other programs are used by a program. This information is available for compiled programs only, and can be displayed, printed, or written to a database output file (OUTFILE).

When a program is created, the information about certain objects used in the program is stored. This information is then available for use with the DSPPGMREF command.

The following table shows the objects for which the high-level languages and utilities save information:

Language or utility Files Programs Data areas See Notes
BASIC Yes Yes No 1
C/400® Language No No N/A  
CL Yes Yes Yes 2
COBOL/400® Language Yes Yes No 3
CSP Yes Yes No 4
DFU Yes N/A N/A  
FORTRAN/400 Language No No N/A  
Pascal No No N/A  
PL/I Yes Yes N/A 3
RPG/400® Language Yes Yes Yes 5
SQL Language Yes N/A N/A  
Notes:
  1. Externally described file references, programs, and data areas are stored.
  2. All system 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 control language (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 command. See the description of the FILE, PGM, and DTAARA parameters on the PARM or ELEM command statements in the Control language (CL) topic.
  3. 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).
  4. CSP programs also save information for an object of type *MSGF, *CSPMAP, and *CSPTBL.
  5. The use of the local data area is not stored.
The stored file information contains an entry (a number) for the type of use. In the database file output of the DSPPGMREF command (built when using the OUTFILE parameter), this is specified as:
Code
Meaning
1
Input
2
Output
3
Input and Output
4
Update
8
Unspecified

Combinations of codes are also used. For example, a file coded as a 7 would be used for input, output, and update.

Related concepts
Control language (CL)
Related reference
Display Program Reference (DSPPGMREF) command