APIs by Example: Keeping Track of Your Exports

Find modules that export procedures with the WRKPGMEXP command.

Sometimes, it’s handy to be able to quickly locate the module or service program that exports a specific procedure, or a specific data item, for that matter. You might, for example, need a particular routine you wrote a while ago but no longer recall in which service program it’s located. Or perhaps you want to write a new procedure but must first ensure that a procedure by that name doesn’t already exist. Because I’ve often encountered such situations, I decided to write the Work with Program Export (WRKPGMEXP) command.

How WRKPGMEXP Works

The WRKPGMEXP command lists all programs and service programs containing modules that export a specified symbol name, which defines either a procedure or data item. For WRKPGMEXP to retrieve the exported symbol names, the modules bound into the programs or service programs must still exist as objects in the library from which they were bound. By using binder language, you can prevent the export of a symbol from a service program, even if the symbol is exported from the module used to create that service program. Therefore, the command supports an option that lets you retrieve symbol names from the service program instead.

A program object doesn’t list the procedures and data items exported from the modules bound into the program because the program itself doesn’t export symbols, but a service program does. A service program exports all symbols defined with the EXPORT keyword in the modules indicated in the Create Service Program (CRTSRVPGM) command if you stipulate *ALL for the command’s export (EXPORT) parameter. Alternatively, specifying EXPORT(*SRCFILE) will export only those symbols declared in the binder language and defined in the source member indicated for the CRTSRVPGM command’s export source file (SRCFILE) and export source member (SRCMBR) parameters.

Download the save file containing the source code.

Read the entire article.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s