Files and Fields – Where Are They Used?

Article ID: 57130

Any time you consider adding or changing a field in a file, you can quickly get a picture of its usage by using this utility, which displays Physical Files, Logical files, Display Files, and Printer file references in programs, service programs, modules, and source code files.

If you forgot the name of a program you worked on weeks ago, but remember it used a certain file, this utility can help you locate it. If you have a situation where a field in a file is getting unusual results, this utility will help you locate programs that update the file.

The utility can use wildcards so you can retrieve all the references to file names MASTER and MASTERL1 (etc.) with just one execution of the command. And as an added feature, you can also display lines of source code containing a particular field name.

Creating the Utility

    Download the source code using the link at the bottom of this article.

    Create a library named UTILXLIB with source files QCLSRC, QCMDSRC, QDDSSRC, and QRPGLESRC.

    Copy the downloaded source code to each respective source member. Use the same name used in the zip file, less the .txt extension.

    Place UTILXLIB at the top of your job's user library list and compile member CLCREATE in QCLSRC to UTILXLIB.

    Run the program CLCREATE on UTILXLIB. This will create all necessary files and compile all programs in UTILXLIB. If required, review the source code of CLCREATE to view each compile command.

    Use your favorite file editor (e.g. DFU) to enter the names of your desired application libraries into the LIBRNAME file.

    To build the reference database required by the utility, run the program IA101CL. This program will run for a while depending on number of objects in the libraries you selected. (If you decide to use this utility regularly, this is the program you will want to run in the early morning hours to refresh the files with the latest changes to your programs.)

Using the Utility

    Enter the command FILEUSE and specify the file name and library of interest. You will get a display of all occurrences of this file in all programs. To specify a wildcard, use the period character for each wildcard position, to have 2 wildcards at the end of MYFILE (i.e. 'MYFILE..').

    After running the FILEUSE command to display/print usage of a select file, you can enter the command FIELDUSE followed by a field name (or character string) contained in the source programs using the file you selected. You will get a display of each occurrence of this field name (or character string) in those source programs.

If you have questions about the utility, you may contact the author, Roger Stein, via email.

See each source member for compile instructions. You can download a zip file containing all the source code here.

Note: As with all new programs, test these routines thoroughly before placing them into a production environment. No warranty is expressed or implied.

ProVIP Sponsors

ProVIP Sponsors