• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Add Powerful Generic Processing to Your Applications

    November 9, 2011 Ted Holt

    Each month I perform a ritual by which I attempt to placate the gods Sarbanes and Oxley. One task involves repeatedly selecting a certain menu option, filling the entry fields with different values each time. What an annoyance. Fortunately there are ways to eliminate repetition programmatically, and the use of generic names is one such way.

    A generic name is one that ends with the asterisk wild-card. Many CL commands accept generic parameters. I have written about this before.

    But when you want to run a certain command over a group of objects, and the command does not allow a generic object name, you’re not out of luck. You just have to do a little work. Here’s an example. This first bit of code contains the source code of a command that accepts a generic file name in a qualified object parameter.

                CMD        PROMPT('Do Something Generically')
    
                PARM       KWD(FILE) TYPE(QUALFILE) MIN(1) MAX(1) +
                             PROMPT('File')      
    
    QUALFILE:   QUAL       TYPE(*GENERIC) DFT(*ALL) SPCVAL((*ALL)) +
                             EXPR(*YES)
                QUAL       TYPE(*NAME) MIN(1) EXPR(*YES) +
                             PROMPT('Library')
    

    I’ve defined a generic name in the first QUAL statement. You may also define generic names in PARM and ELEM statements.

    Defining a generic name does one thing: it tells the CL command processor to allow a generic name in an input entry blank. Defining a generic name does not create a list, as globbing does in Qshell and other shells of the Unix flavor. You have to create the list yourself.

    If the generic name refers to objects, creating the list of objects is easy. I use the Display Object Description (DSPOBJD) command to build a list of files in an outfile, as show below:

    pgm  parm(&inFile)
    
       dcl   &inFile     *char    20
       dcl   &FileName   *char    10
       dcl   &LibName    *char    10
    
       dclf  qadspobj  opnid(fd)
    
       chgvar   &FileName    %sst(&inFile  1 10)
       chgvar   &LibName     %sst(&inFile 11 10)
    
       dspobjd  obj(&LibName/&FileName) objtype(*file) +
                  output(*outfile) outfile(qtemp/objd)
    
       ovrdbf   qadspobj   tofile(qtemp/objd)
       dowhile  '1'
          rcvf    opnid(fd)
          monmsg  cpf0864  exec(leave)
          /* do something with fd_odobnm */
       enddo
    
       dltovr     qadspobj
    

    This command-processing program generates a list of objects.

    I could also use the List Objects (QUSLOBJ) API. The API would execute faster, but I’ve never gotten around to developing that solution.

    Notice the comment inside the DOWHILE loop. This is where you reference the object name that was just retrieved from the outfile in QTEMP. What you do here is limited only by your imagination.

    As I just said, you might run a command that does not allow a generic parameter. If it’s a command that you cannot modify, such as one of IBM‘s commands, you have a way to run that command generically. And if the command is one to which you do have source code, you may find it easier to create this new command and CL program than to add generic processing to the executed command.

    Or you might call a program, possibly using the information from the outfile to build a necessary override. Or you could run a Qshell script. What you do here depends on your application.

    In my programming, I have only used generic parameters with object names, but nothing stops you and me from using them with other types of data. For instance, you could define a generic vendor number or a generic customer name. In such a case, you would probably define the parameter to be of character data type, rather than generic. It would be up to you, of course, to write the code to turn the generic value into a list.

    RELATED STORIES

    Commands with Generic Parameters

    Deleting with a Generic File Name

    The Art of Globbing



                         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

    Migrate IBM i with Confidence

    Tired of costly and risky migrations? Maxava Migrate Live minimizes disruption with seamless transitions. Upgrading to Power10 or cloud hosted system, Maxava has you covered!

    Learn More

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Shield Advanced Solutions:  Access IBM i data & objects from Linux & Windows Servers using PHP
    Dan Riehl Presents:  Fall Training Sale – Discounts up to 40%! RPG IV COBOL CL Admin Security
    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

    Kronos Launches New InTouch Time Clock A Radical Idea For IBM i Software Pricing

    Leave a Reply Cancel reply

Volume 11, Number 34 -- November 9, 2011
THIS ISSUE SPONSORED BY:

WorksRight Software
ProData Computer Services
Twin Data Corporation

Table of Contents

  • Add Powerful Generic Processing to Your Applications
  • Meet JSON
  • Admin Alert: When You Can’t Answer Record Lock Errors

Content archive

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

Recent Posts

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

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