• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Vincent’s Standards

    June 16, 2004 Dear Readers

    As I mentioned in “Effective Messaging, IBM’s Way,” a reader named Vincent had some good ideas that are standards in his shop. All of them are simple, common-sense tips that can make life run a little smoother. I offer them to you for your consideration, along with a few comments and examples of my own that follow in italic type.

    –Ted

    1. If you call QCMDEXC, use SNDPGMMSG MSGTYPE(*INFO) to display the command to be run in the job logs for later debugging.

    The job log shows a call to QCMDEXC, but not the parameter values. Instead, there is a message that says, “The CALL command contains parameters.” The following example logs the parameters to the job log.

    SNDPGMMSG  MSG('Command: "' *CAT &CMD *CAT '"')
    CALL QCMDEXC (&CMD 80)
    

    2. For all CL program calls, use SNDPGMMSG MSGTYPE(*INFO) to display the parameters in the job logs for later debugging.

    This is a generalization of the previous tip. The job log shows calls to programs, but not the parameter values. The following example logs the parameters to the job log.

    SNDPGMMSG  MSG('Parms> File:' *BCAT &FILE *BCAT 'Lib:' +
             *BCAT &LIB)
    CALL SOMEPGM (&FILE &LIB)
    

    3. Always put the program/query name in the header of all reports.

    Don’t hard-code the program name, if you can avoid it. You can waste a lot of time before you figure out that the report that pretends to come from program XYZ was really produced by a clone of program XYZ.

    RPG programs can get the program name from the first 10 positions of the Program Status Data Structure, which is also known as subfield *PROC. The following two code snippets are equivalent.

    D                sds
    D  PgmName          *proc
    
    D                sds
    D  PgmName                1     10
    

    To learn how to make a CL program determine its own name, see “Make a CL Program or Module Retrieve Its Name.”

    4. When a query generates a report, use the OVRPRTF file(QPQUPRFIL) SPLFNAME(xxx), where xxx is the query name. Optionally, use the USRDTA keyword to describe the report.

    5. All reports should have a last line showing “end of report.”

    This prevents users from guessing whether their reports completed. A reader named Andrew adds more information to the last line.

    6. The RUNQRY command should always include all of the files used in the QRYFILE keyword, with either *LIBL or QTEMP as the library. This is so the program can be run in a testing library.

    You can also override a database file that Query is building. Using the value *LIBL or QTEMP provides complete dependence on the library list, which is good for testing.

    7. Do not use MULT 10000.0001 (or any variation thereof) to convert dates from CYMD to MDCY. This is a good trick, but it is a very inefficient date conversion method that does have a big effect on performance.

    In spite of seeing this warning many times over the past 20 or so years, I still see plenty of code that uses this technique.

    8. Do not hard-code any library name other than QTEMP.

    This is a great idea, but to pull it off requires putting some thought into job descriptions.

    9. Do not use DLTOVR(*ALL). You could accidentally delete overrides elsewhere in the job stream. Specify the overrides individually.

    Better yet, don’t use overrides if you can put the information in a file description.

    10. If a printer file is defined with anything other than the default page size, put the necessary values for the parameters of the Create Printer File (CRTPRTF) command in comments in the source code and create the printer file with those parameter values. Do not use the Override with Printer File (OVRPRTF) command in a CL procedure to change them. OVRPRTF should be used for changing output queue, USRDTA, PRTTXT, HOLD, SAVE, and number of copies.

    Even if a printer file is not externally described, creating a printer file to hold settings such as page size and form type is a good idea.

    11. If you have a program that remains open (indicator LR is *OFF), make sure that you close it when you’re finished or run the Reclaim Resource (RCLRSC) command.

    My favorite way to handle this is to call the program with no parameters. The called program uses the %PARMS built-in function to determine the number of parameters passed to the program. If that value is zero, the program sets on LR and shuts down immediately.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    ARCAD Software

    [Webinar] Creating test data, easily and quickly!

    June 22 at 12 p.m. EST

    Software testing needs realistic, consistent data available on demand, where and when needed. However, providing testers with a copy of the entire production database is costly both in time and disk space.

    In this webinar, we’ll demonstrate how to:

    • Easily create coherent test datasets, small enough for rapid test cycles, but large enough to accurately reflect the variety of production data
    • Anonymize the datasets to protect any PII
    • Inject into test environments in a snap

    Join us on this webinar with Alan Ashley, solution architect, and learn how to subset your data.

    Register now!

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Bowstreet Brings ‘Portlet Factory’ to iSeries The AS/400: 16 Years of Bending, Not Breaking

    Leave a Reply Cancel reply

Volume 4, Number 20 -- June 16, 2004
THIS ISSUE
SPONSORED BY:

T.L. Ashford
Damon Technologies
Guild Companies

Table of Contents

  • V5R3 Advances DB2 UDB for iSeries
  • Effective Messaging, IBM’s Way
  • Vincent’s Standards

Content archive

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

Recent Posts

  • IBM i Delivers Sizable Benefits, Forrester Consulting Reports
  • SBOMs Will Come to IBM i, Eventually
  • IBM i Backup Provider Storagepipe Snapped Up By Thrive
  • Four Hundred Monitor, June 7
  • IBM i PTF Guide, Volume 25, Number 23
  • Power10 Boosts NVM-Express Flash Performance
  • Fortra Completes Postmortem Of GoAnywhere Vulnerability
  • Guru: Binding Directory Entries
  • How Does Your Infrastructure Spending Stack Up To The World?
  • IBM i PTF Guide, Volume 25, Number 22

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