Write PDM Scans to Database Files
June 8, 2011 Ted Holt
Note: The code accompanying this article is available for download here. My shop licenses a documentation package that tells us all sorts of useful information, such as which programs use which files and which programs call which programs. Nevertheless, we still use PDM string searches to search source code. I wrote a utility that makes such searches more powerful. Maybe you’ll find it beneficial. How To Search Using PDM You have two ways to search source code with PDM. You can use option 25 from the WRKOBJPDM and WRKMBRPDM displays, or you can use the Find String Using PDM (FNDSTRPDM) command. In either case, you’re presented with a display in which you can specify:
See Figure 1 for an example.
Limitations of the Search PDM searches are useful, but they’re limited.
For a recent project, my shop needed to search for various strings in source files in several libraries. We wanted to put information about the matched source members in a database file. For these reasons, I wrote the LOGSCANSRC utility. The Utility LOGSCANSRC consists of these objects:
In addition, we defined a PDM option to invoke the LOGSCANSRC command when the system finds a match. You can use a combination that is not in use on your system. I’ll use LZ for this example. Here’s the command string for the PDMoption. LOGSCANSRC SRCFILE(&L/&F) MBR(&N) TYPE(&T) How To Search Using the Utility To write search results to the database files, you’ll use the usual PDM option 25 to start the scan. You’ll get the usual search display, shown in Figure 2, but you must fill in some of the entry fields in a certain manner.
Fill in the first four fields just as you would for any search. In the Option field, enter the PDM option that you defined to run LOGSCANSRC. We’re using LZ in this example. Last, in the Parameters field, enter the CMT parameter that you want passed to LOGSCANSRC. I load this parameter with the find string so that I will know which search strings are found in each source member. After you press Enter, the scan precedes as normal, except that each “hit” causes an invocation of LOGSCANSRC, which writes to the database files. Since each match adds to the database files, it is up to you to clear the database files when appropriate. Querying the Results Use tools of your choice to view the results of the scan. Here’s the SCANMBRS file after searching all the source members of a library for two strings, HOUSE and WHS. LIBRARY FILE MEMBER TYPE SOMELIB QCLSRC AP200C CLP SOMELIB QCLSRC IN390C CLP SOMELIB QCMDSRC SETAPHZN CMD SOMELIB QRPGLESRC AMM62 RPGLE SOMELIB QRPGLESRC AP002R RPGLE SOMELIB QRPGLESRC AP009R RPGLE SOMELIB QRPGLESRC IN925R RPGLE SOMELIB QRPGLESRC MRP488R RPGLE SOMELIB QRPGLESRC MRP620R RPGLE SOMELIB QRPGSRC IN037R RPG And here is the comments file: LIBRARY FILE MEMBER SEQUENCE COMMENT SOMELIB QCLSRC AP200C 1 HOUSE SOMELIB QCLSRC IN390C 1 HOUSE SOMELIB QCMDSRC SETAPHZN 1 HOUSE SOMELIB QRPGLESRC AP002R 1 HOUSE SOMELIB QRPGLESRC AP009R 1 HOUSE SOMELIB QRPGLESRC IN925R 1 HOUSE SOMELIB QRPGLESRC MRP488R 1 HOUSE SOMELIB QRPGLESRC MRP620R 1 HOUSE SOMELIB QRPGSRC IN037R 1 HOUSE SOMELIB QCLSRC AP200C 2 WHS SOMELIB QCLSRC IN390C 2 WHS SOMELIB QCMDSRC SETAPHZN 2 WHS SOMELIB QRPGLESRC AP002R 2 WHS SOMELIB QRPGLESRC AP009R 2 WHS SOMELIB QRPGLESRC IN925R 2 WHS SOMELIB QRPGLESRC MRP488R 2 WHS SOMELIB QRPGLESRC MRP620R 2 WHS SOMELIB QRPGSRC IN037R 2 WHS Miscellaneous Information I want you to know a few more things. First, PDM capitalizes the comment data before sending it to the LOGSCANSRC command. I don’t like it, but it’s beyond my control. Second, program SCAN001R won’t write a duplicate comment, as there’s no need for it. Last, you might want to add more fields to SCANMBRS for your own use. These are some additional fields that we included.
Use your imagination. If you use string searches, then I hope you find LOGSCANSRC to be useful.
|
not able to open code folder, giving error website not found