fhg
Volume 9, Number 8 -- March 4, 2009

Send Messages Unto Others

Published: March 4, 2009

by 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


Sponsored By
COMMON

Register today for COMMON's 2009 Annual Meeting & Exposition, April 26 - 30, 2009, in Reno, Nevada, at the Grand Sierra Resort and Casino - learn more at www.common.org/annualmeeting

This premier Power Systems educational and networking event is COMMON's largest event of the year, offering five full days of IBM i and AIX education, evening networking socials, and the largest Power Systems-related Exposition to supplement your education. The Annual Meeting will feature well over 500 educational sessions, hands-on labs, and all-day workshops covering a wide variety of topics. All sessions are delivered by the most respected and knowledgeable presenters in the industry. Highlights include:

  · Providing attendees with over 500 educational sessions to choose from over five days on
     IBM i and AIX-related topics.
  · The most cost-effective conference option available to meet your 2009 Power Systems-related
     educational needs.
  · All-day pre-conference workshops providing an unprecedented opportunity to gain in-depth
     and wide-ranging education that will immediately impact your daily work.
  · The largest Exposition of its kind, giving you the ability to supplement your education
     with the latest Power Systems-related solutions available.
  · Over 80 vendors present in the Exposition to experience first-hand the next generation of
     technologies and solutions that you can implement immediately.
  · Special keynote address during Opening Session by Jeff Jonas, IBM Distinguished Engineer
     and Chief Scientist, Entity Analytic Solutions, IBM Software Group.
  · Extraordinary networking opportunities with other members of the COMMON community.
  · Having fun and sharing with your peers, renowned speakers, IBM executives, and
     fellow members.

Best Conference Value in 2009
The broad range of education on IBM i and AIX topics, the non-stop networking opportunities, and the largest Power Systems-related Exposition make the COMMON Annual Meeting an invaluable conference event. In fact, when you consider value of holding this event in Reno, this Annual Meeting is the most cost-effective Power Systems educational conference option in 2009.

Largest Power Systems-related Exposition
You will also have access to the world's largest Power System-related Exposition, which encompasses more that 80 of the leading industry exhibitors, including a large IBM presence. The COMMON Exposition provides a one-stop source of up-to-the-minute information and products for the IT industry. Discover what's new in the Power Systems world, and learn how you and your company can reduce costs and improve productivity by leveraging the products and services featured at the COMMON Exposition. It's a great way to supplement your education with hands-on exposure to the latest products and solutions available.

Invaluable Networking
In addition to the leading edge education, the Annual Meeting and Exposition provides an invaluable networking forum for attendees to interact with their Power Systems community. After a full day of education, the evening "Power Down" social events provide attendees the opportunity to relax, have some fun, and exchange knowledge and real-world experiences with fellow attendees, speakers, solution providers and IBM. The contacts you make at the conference will be as valuable as the education you receive.

The COMMON 2009 Annual Meeting and Exposition is a Power Systems educational
and networking event that you and/or your team won't want to miss.

To learn more about the conference visit www.common.org/annualmeeting


Senior Technical Editor: Ted Holt
Technical Editor: Joe Hertvik
Contributing Technical Editors: Edwin Earley, Brian Kelly, Michael Sansoterra
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

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


 
The Four Hundred
IBM Adds i Shops to Expanded p Shop Trade-In Deal

IBM and Resellers Do the iLoyalty Blitz

Server Sales Slumped As 2008 Stumbled to the Holidays

Mad Dog 21/21: That'll Teach 'Em

Healthcare and Utilities Lead Vertical Markets in IT Spending

Four Hundred Stuff
xTuple Reports Strong Growth of Open Source ERP

LaserVault Shrinks System i Backups with Data De-Duplication

Paglo Adds 'NetFlow' to IT Search Service

Vision Debuts 'PowerPacks' Product Bundles

WIS:DOM Hooks Up with ACOM

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar

System i PTF Guide
February 28, 2009: Volume 11, Number 9

February 21, 2009: Volume 11, Number 8

February 14, 2009: Volume 11, Number 7

February 7, 2009: Volume 11, Number 6

January 31, 2009: Volume 11, Number 5

January 24, 2009: Volume 11, Number 4

TPM at The Register
AMD: 'At heart, we're a design company'

EMC facing DoJ probe

Gartner: PC sales, except netbooks, to slump in 2009

Citrix taps VMLogix for fake server jukeboxing

IDC chops 2009 IT spending forecasts (again)

Sun powers Niagara hypervisor update with IBM speed boast

HP iron still haunted by ghost of Compaq

Novell spills sales after pipe breakage

Big Blue flaunts Meltdown-proof coating

VMware, Novell hatch virtual appliance scheme

Microsoft plays with small, sleepy servers

Server sales cratered in Q4, says IDC

Super Micro squeezes four servers into one chassis

Gartner: Global IT spending will rise in 2009 (slightly)

THIS ISSUE SPONSORED BY:

Help/Systems
COMMON
System i Developer


Printer Friendly Version


TABLE OF CONTENTS
A Bevy of BIFs: %XLATE and %REPLACE

Send Messages Unto Others

Admin Alert: Things I Learned About IBM Maintenance Contracts

Four Hundred Guru

BACK ISSUES

From the IT Jungle Forums
Insert via Java

iSeries Access for Web

Mimix installation and configuration docs

EDI Inovis Programmer - Heavy Duty Problem Solver - Anytime

Data Queues vs. MQ Series: Performance

Removing blanks from a CL Variable

XML




 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2009 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement