Retrieve module information with the aid of the WRKMODREF command.
I’ve presented several commands in the APIs by Example column that aim to let you resolve cross-references in an ILE development environment. These commands include Work with Service Program References (WRKSPGREF), Work with Program Imports (WRKPGMIMP), and Work with Program Exports (WRKPGMEXP). Today, I’ll add the Work with Module References (WRKMODREF) command to this collection. For instructions on how to create WRKMODREF, see the “How to Compile” section below.
How WRKMODREF Works
Ideally, a module is bound into only one program or service program object. If you need a given module’s functionality in more than one program, you’d place that module in a service program. This technique makes the module’s function available to all programs that need it by letting these programs import the encapsulating subprocedure from the service program. For whatever reason, though, sometimes the ILE design guideline of keeping a module in one place isn’t always followed. But sooner or later, you’ll have to locate the programs or service programs containing a specific module because of a pending revision of the module, or ensure that all versions of the bound module are at the current level.
The WRKMODREF command employs two Program and CL Command APIs to retrieve program and module information: Retrieve Program Information (QCLRPGMI) and Retrieve Module Information (QBNRMODI), respectively. The QCLRPGMI API retrieves the program type to identify whether a program is an OPM- or ILE-type program; the QBNRMODI API returns module source, timestamp, and library attributes.