• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Send Messages Unto Others

    March 4, 2009 Ted Holt

    I’ll never forget the guy who used to call my telephone with a cheery “My computer won’t compute!” whenever he had a problem. Ambiguous appeals for help annoy me to no end. The least a guy can do is give me something to go on; some information to give me a place to start to look for his problem. But in fairness to users, I often find that they don’t have much information to give me because the programmer didn’t make the program tell them anything. A crafty CL programmer knows how to easily avoid such situations.

    When something goes wrong, send a message to the user. But don’t send any old message–make it a descriptive message! Here’s how.

    First, create a message file, if you don’t have one already. The following CL command creates a message file called AUSRMSG in library TOOLS.

    crtmsgf msgf(tools/ausrmsg)
    

    Next, design a descriptive message, keeping the following ideas in mind.

    1. Write a short message of 76 characters or less.
    2. Write a longer, more detailed message.
    3. Include placeholders (numbers prefixed with ampersands) in both of the aforementioned message texts. This is how you make your messages descriptive by replacing placeholders with appropriate text at run time.

    For example, here’s a short message:

    xxxxxxxxxxxxxxxxxxxxxxxxx canceled; xxxxx errors were found.
    

    Here’s a longer message:

    The xxxxxxxxxxxxxxxxxxxxxxxx application ended abnormally.
    Status is xxxxxxxx.
    You must correct the errors before you can continue.
    

    I have left three placeholders: application name, status code, and number of errors.

    Here’s the Add Message Description command that implements the message description.

    addmsgd msgid(usr1001) msgf(tools/ausrmsg) +
       msg('&1 canceled; &3 errors were found.') +
       seclvl('The &1 application ended abnormally. Status +
           is &2. You must correct the errors before you +
            can continue.') +
       sev(90) +
       fmt((*char 24) (*char 8) (*bin 2)) 
    

    Notice the three placeholders: &1, &2, and &3. The FMT parameter defines them to be 24-byte character, 8-byte character, and 2-byte signed binary (integer) respectively.

    The following program fragments illustrate how to use the message description. Program PAYEDIT returns the number of errors it finds in a payroll batch through the second parameter. If this number is more than zero, the program cancels, sending a descriptive message to the caller.

    dcl   &AppName       *char     24   value(' Payroll edit')
    dcl   &AppStatus     *char      8
    dcl   &NbrErrors     *dec       5
                                     
    dcl   &Bin2          *char      2
    
    call PayEdit parm(&AppStatus &NbrErrors)
    if (&NbrErrors *gt 0) do
       chgvar   var(%bin(&Bin2 1 2)) value(&NbrErrors)
       chgvar   var(&MsgDta)  value(&AppName *cat &AppStatus *cat &Bin2)
       sndpgmmsg msgid(usr1001) msgf(ausrmsg) msgdta(&msgdta) +
                    msgtype(*escape)
    enddo
    

    Since CL cannot concatenate decimal values into a string, I defined the third parameter as integer, which can be copied bit-for-bit into a character value using the %BIN function.

    The user sees the following in the message line at the bottom of his screen (or you see it his job log):

    Payroll edit canceled; 3 errors were found.
    

    If he positions the cursor to the messages and presses F1, he sees the second-level text:

    The Payroll edit application ended abnormally. Status is 25-32126.
    You must correct the errors before you can continue. 
    

    If you need to send more than one message in response to an error, send all of them except for the last one as diagnostic messages.

    sndpgmmsg msgid(usr1236) ... msgtype(*diag)
    sndpgmmsg msgid(usr6642) ... msgtype(*diag)
    sndpgmmsg msgid(usr3285) ... msgtype(*diag)
    sndpgmmsg msgid(usr1124) ... msgtype(*escape)
    

    Put yourself in the user’s place. Send messages unto others as you would have messages sent unto you.



                         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
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    System i Developer:  RPG & DB2 Summit in Orlando, April 15-17 for 3 days of serious training
    ARCAD Software:  FREE Webinar and White Paper, How ALM Can Save You Money
    COMMON:  Join us at the 2009 annual meeting and expo, April 26-30, Reno, Nevada

    IT Jungle Store Top Book Picks

    Easy Steps to Internet Programming for AS/400, iSeries, and System i: List Price, $49.95
    Getting Started with PHP for i5/OS: List Price, $59.95
    The System i RPG & RPG IV Tutorial and Lab Exercises: List Price, $59.95
    The System i Pocket RPG & RPG IV Guide: List Price, $69.95
    The iSeries Pocket Database Guide: List Price, $59.00
    The iSeries Pocket Developers' Guide: List Price, $59.00
    The iSeries Pocket SQL Guide: List Price, $59.00
    The iSeries Pocket Query Guide: List Price, $49.00
    The iSeries Pocket WebFacing Primer: List Price, $39.00
    Migrating to WebSphere Express for iSeries: List Price, $49.00
    iSeries Express Web Implementer's Guide: List Price, $59.00
    Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95
    Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
    Getting Started with WebSphere Express for iSeries: List Price, $49.00
    WebFacing Application Design and Development Guide: List Price, $55.00
    Can the AS/400 Survive IBM?: List Price, $49.00
    The All-Everything Machine: List Price, $29.95
    Chip Wars: List Price, $29.95

    Prepare Now for Volatile Supply Chains, IBM Study Says Getting Dizzy from Dynamic Infrastructure

    Leave a Reply Cancel reply

Volume 9, Number 8 -- March 4, 2009
THIS ISSUE SPONSORED BY:

Help/Systems
COMMON
System i Developer

Table of Contents

  • A Bevy of BIFs: %XLATE and %REPLACE
  • Send Messages Unto Others
  • Admin Alert: Things I Learned About IBM Maintenance Contracts

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