• 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

    Embrace VS Code for IBM i Development

    The IBM i development landscape is evolving with modern tools that enhance efficiency and collaboration. Ready to make the move to VS Code for IBM i?

    Watch this webinar where we showcase how VS Code can serve as a powerful editor for native IBM i code and explore the essential extensions that make it possible.

    In this session, you’ll discover:

    • How ARCAD’s integration with VS Code provides deep metadata insights, allowing developers to assess the impact of their changes upfront.
    • The role of Git in enabling seamless collaboration between developers using tools like SEU, RDi, and VS Code.
    • Powerful extensions for code quality, security, impact analysis, smart build, and automated RPG conversion to Free Form.
    • How non-IBM i developers can now contribute to IBM i projects without prior knowledge of its specifics, while ensuring full control over their changes.

    The future of IBM i development is here. Let ARCAD be your guide!

    Watch the replay 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

    One thought on “Write PDM Scans to Database Files”

    • Vijay Chandra says:
      July 27, 2023 at 7:24 am

      not able to open code folder, giving error website not found

      Reply

    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

  • POWERUp 2025 –Your Source For IBM i 7.6 Information
  • Maxava Consulting Services Does More Than HA/DR Project Management – A Lot More
  • Guru: Creating An SQL Stored Procedure That Returns A Result Set
  • As I See It: At Any Cost
  • IBM i PTF Guide, Volume 27, Number 19
  • IBM Unveils Manzan, A New Open Source Event Monitor For IBM i
  • Say Goodbye To Downtime: Update Your Database Without Taking Your Business Offline
  • i-Rays Brings Observability To IBM i Performance Problems
  • Another Non-TR “Technology Refresh” Happens With IBM i TR6
  • IBM i PTF Guide, Volume 27, Number 18

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 © 2025 IT Jungle