• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • 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:

    • The string you’re looking for
    • The range of columns of text to search
    • Whether to match or ignore case
    • What to do when the system finds a match
    • How to format printed output from the search

    See Figure 1 for an example.

    Figure 1.

    Limitations of the Search

    PDM searches are useful, but they’re limited.

    • You can only search for one string at a time. What if you want to find all members that contain any of two or more strings?
    • You can’t search more than one library in a single search.
    • The system outputs the results to display or print only.

    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:

    Object

    Type

    Description

    SCANMBRS

    Physical file

    Members that contain
    the search strings

    SCANCMTS

    Physical file

    Comments about the
    members

    SCAN001R

    RPGLE program

    Writes member
    information to the physical files

    LOGSCANSRC

    Command

    Command interface to
    program SCAN001R

    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.

    Figure 2.

    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.

    • A flag to tell whether or not we needed to modify the member as part of our project.
    • A user profile to tell which developer was assigned to modify the member.
    • A date when the member was deemed ready for production.

    Use your imagination.

    If you use string searches, then I hope you find LOGSCANSRC to be useful.



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    ARCAD Software

    [Webinar Series] Demystifying DevOps on the IBM i

    Join us for a 3-part “Live” Roundtable webinar series as we demystify DevOps on the IBM i.  We’ll start with discussions on Git and the IBM i and developer tool options.  Next, we will cover Branch Management and Builds. We’ll end with discussions on an Automated DevOps Workflow.  It will be an informative series on modernizing the IBM i development process. Our speakers will address your questions and share their years of experience and best practices.

    Register NOW

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Profound Logic Software:  FREE Webinar: RPG Open Access and Rich Display Files. June 9
    SEQUEL Software:  View the recorded Webinar: 10 Ways SEQUEL Makes Developers More Productive
    RJS Software Systems:  Go paperless, automate business process and save money

    IT Jungle Store Top Book Picks

    BACK IN STOCK: Easy Steps to Internet Programming for System i: List Price, $49.95

    The iSeries Express Web Implementer's Guide: List Price, $49.95
    The iSeries Pocket Database Guide: List Price, $59
    The iSeries Pocket SQL Guide: List Price, $59
    The iSeries Pocket WebFacing Primer: List Price, $39
    Migrating to WebSphere Express for iSeries: List Price, $49
    Getting Started with WebSphere Express for iSeries: List Price, $49
    The All-Everything Operating System: List Price, $35
    The Best Joomla! Tutorial Ever!: List Price, $19.95

    MyEclipse Blue Edition 9.0 Offers RAD Alternative The Power Systems-IBM i Road Ahead

    Leave a Reply Cancel reply

Volume 11, Number 18 -- June 8, 2011
THIS ISSUE SPONSORED BY:

ProData Computer Services
WorksRight Software
Twin Data Corporation

Table of Contents

  • ILE: Decisions, Decisions, Part 1
  • Write PDM Scans to Database Files
  • Admin Alert: Things I Learned from My Latest Power i Upgrade

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • The IBM i Power10 Upgrade Cycle Forecast Looks Favorable
  • White Hats Completely Dismantle Menu-Based Security
  • Cloud Software To Drive Enterprise Application Growth
  • How Do You Stay In Touch With The IBM i Community?
  • IBM i PTF Guide, Volume 25, Number 6
  • Security Still Top Concern, IBM i Marketplace Study Says
  • Bob Langieri Shares IBM i Career Trends Outlook for 2023
  • Kisco Brings Native SMS Messaging to IBM i
  • Four Hundred Monitor, February 1
  • 2023 IBM i Predictions, Part 4

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2022 IT Jungle

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.