• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Now Where Did I Leave That Source Member?

    September 14, 2011 Bruce Guetzkow

    Note: The code accompanying this article is available for download here.

    During execution, programs rely strictly on their compiled objects. The source used to create the object is not used in any way for execution. There are, however, some instances where source is of value during processing.

    In a source member, one could store FTP commands to be used with the FTP (Start TCP/IP File Transfer) command, SQL statements to be used with the RUNSQLSTM (Run SQL Statements) command, or REXX statements to be used with the STRREXPRC (Start REXX Procedure) command. Knowing where the proper source exists is critical to executing those commands.

    Each of those commands, and most others like them, allow you to specify the source file and indicate a library of *LIBL. When the commands execute, the library list is scanned and the first library containing the specified source file is used. Often this is sufficient to find the source member in question. However, if there are multiple libraries in the list with the same source file name, and the first library is not the one needed, then *LIBL won’t work. So, sometimes it works, sometimes it doesn’t. (See File Members and the Library List for more information.) You can, of course, hard code the proper library name, but hard coding leads to other problems.

    What is needed is a programmatic solution, and IBM has given us just that in the form of an API: QUSRMBRD (Retrieve Member Description). By specifying the member name and source file (you can also specify a data file) with a library name of *LIBL, API will return the library that contains the source file and source member. Now if you have multiple libraries in your library list with the same source file name, you can be assured that you will be able to retrieve the source member needed. To simplify things further, I’ve created a simple procedure that you can install into a service program that can be bound into any program.

    The procedure accepts just two parameters: the name of the source file (i.e., QSQLSRC), and the name of the member (i.e., MYMBRNAME). The procedure returns the name of the library, or fills the return value with asterisks if none is found. As currently written, you will need to pass both of the parameters in as uppercase values. You could also modify the procedure to convert the parameters to uppercase.

    The procedure has only a few executable lines of code. First, the standard error data structure used by many IBM APIs is reset to default values. The API is then called. If errors are found, the library name is set to all-asterisks. Last, the library name is returned to the caller through a variable parameter, which you can use in the library parameter of the appropriate command.

    The QUSRMBRD API has seven parameters. The last two are optional, but are used in this example:

    • Receiver Variable–The results of the API call are placed into this data structure
    • Length of Receiver Variable–The length of the data being returned
    • Format Name–The format used for this example is MBRD0100, though four others exist
    • Qualified Database File Name–10 characters of file name, 10 characters of library name
    • Override Processing–No overrides are used
    • Error Code–Standard IBM API Error Data Structure
    • Find Member Processing–‘1’ is the most efficient value to use when *LIBL is the library name

    You’ll find this utility in the downloadable code. There are two source file members: an RPG source member and the corresponding prototype.

    That’s it. You can check out the documentation in the IBM Information Center for other values returned by this format and the other formats available in the event that you need more than just the library name. Happy source-hunting!

    Bruce Guetzkow, an independent IBM i programming consultant with GmanTech Consulting in southeastern Wisconsin, is a firm believer in practical programming. For over 25 years he has developed applications for IBM systems from mainframe to System/36 to IBM i on Power. You can read his Website blog, follow him on Twitter (@gmantechi), or catch him at a meeting of the Wisconsin Midrange Computer Professional Association (WMCPA), where he is the current webmaster. Send your questions or comments for Bruce to Ted Holt via the IT Jungle Contact page.

    RELATED STORY

    File Members and the Library List



                         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
    Maxava

    Disaster Recovery Strategy Guide for IBM i

    Practical tools to implement disaster recovery in your IBM i environment. Fully optimized to include cloud recovery, replication and monitoring options.

    Download NOW!

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    PowerTech:  2011 Security Event of the Year. September 22–23 in Las Vegas. RVSP today!
    Botz & Associates, Inc.:  FREE Single Sign-On video tutorial and ROI Calculator
    ProData Computer Services:  Learn how to access remote data -- RDB Connect On-Demand Webinar

    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

    Rimini Gets ISO:9001 Certification Windows/400: Windows On Power Systems, Take Five

    Leave a Reply Cancel reply

Volume 11, Number 26 -- September 14, 2011
THIS ISSUE SPONSORED BY:

WorksRight Software
Bytware
System i Developer

Table of Contents

  • Learn To Debug Authority Failures, Part 1
  • Now Where Did I Leave That Source Member?
  • Admin Alert: Three Common Problems with CBUs

Content archive

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

Recent Posts

  • 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
  • Will The Turbulent Economy Downdraft IBM Systems Or Lift It?
  • How IBM Improved The Database With IBM i 7.6
  • Rocket Celebrates 35th Anniversary As Private Equity Owner Ponders Sale
  • 50 Acres And A Humanoid Robot With An AI Avatar
  • IBM i PTF Guide, Volume 27, Number 17

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