fhg
Volume 9, Number 36 -- November 18, 2009

Message Received, But Not Understood

Published: November 18, 2009

Hey, Ted:

I had a problem last week. I was monitoring for error messages after an Add Physical File Member (ADDPFM) command in a CL program. Well, OS/400 sent two CPF messages when ADDPFM failed. MONMSG would only trap the second message, but I wanted to trap the first one because that's the one that tells me what went wrong. What do I need to do?

--Chris


This seems like a good time to review some messaging fundamentals. Chris is not a newbie programmer, so if he doesn't understand, there are probably others who don't understand either.

When a CL command fails, it often sends more than one message. All messages except the last one are diagnostic messages. Their purpose is to provide more information about the error. The last message is an escape message. Its role is to notify the caller that the command failed, but it may also, like the diagnostic messages, impart information about the error.

For example, if ADDPFM tries to add a member, but the file already has the maximum number of members, the system sends two messages: diagnostic message CPF3213 (Members for file DOGPOUND more than maximum allowed); and escape message CPF7306 (Member PHIDEAUX not added to file DOGPOUND in THEBIGCITY).

Likewise, if ADDPFM tries to add a member that already exists, the system sends two messages: diagnostic message CPF5812 (Member PHIDEAUX already exists in file DOGPOUND in library THEBIGCITY); and escape message CPF7306 (Member PHIDEAUX not added to file DOGPOUND in THEBIGCITY).

Notice that the same escape message is sent in both instances.

Chris wanted his program to determine why the ADDPFM command failed so that his program could pursue different courses of action according to the cause of the failure. The escape message, the only one he could monitor for, told him only that the command failed. The reason why it failed was in the diagnostic message.

It is necessary to use the Receive Message (RCVMSG) command to get the diagnostic message. The following example shows one way to achieve this goal.

PGM        PARM(&MBR)

   DCL        VAR(&MBR)        TYPE(*CHAR) LEN(10)
   DCL        VAR(&ERRORMSGID) TYPE(*CHAR) LEN( 7)
   DCL        VAR(&MSGTYPE)    TYPE(*CHAR) LEN( 2)

   ADDPFM     FILE(DOGPOUND) MBR(&MBR)
   MONMSG     MSGID(CPF7306) EXEC(DO)

      RCVMSG     MSGTYPE(*LAST) RMV(*YES) MSGID(&ERRORMSGID) +
                          RTNTYPE(&MSGTYPE) /* escape msg */
      RCVMSG     MSGTYPE(*LAST) RMV(*YES) MSGID(&ERRORMSGID) +
                          RTNTYPE(&MSGTYPE) /* diagnostic msg */

      IF         COND(&MSGTYPE *NE '02') THEN(DO)
         /* Do something here; the last message should have */
         /* been a diagnostic message, but it wasn't.   */
         CHGVAR     VAR(&ERRORMSGID) VALUE(' ')
      ENDDO

      SELECT
         WHEN       COND(&ERRORMSGID *EQ 'CPF5812') THEN(DO)
            /* The dog is already there */
            /* Do something */
         ENDDO
         WHEN       COND(&ERRORMSGID *EQ 'CPF3213') THEN(DO)
            /* The pound is full; no room for one more */
            /* Do something */
         ENDDO
         OTHERWISE  CMD(DO)
            /* Something else went wrong */
            /* Do something */
         ENDDO
      ENDSELECT

   ENDDO

ENDPGM

The MONMSG kicks in when the ADDPFM fails. The first RCVMSG retrieves the last message that was sent to the program message queue, which is the escape message, CPF7306. The second RCVMSG retrieves the message before that, which should be the diagnostic message. I've included an IF that verifies that the message was a diagnostic message (message type 02), just in case, because I'm the epitome of conservatism.

Besides retrieving the message type, the second RCVMSG command also retrieves the message ID. This is the information that Chris wanted, the one he needs in order to decide how to proceed.

--Ted




                     Post this story to del.icio.us
               Post this story to Digg
    Post this story to Slashdot


Sponsored By
HELP/SYSTEMS

SEQUEL ViewPoint®--Data Access & Analysis
for Power Systems™ Servers

                                               · Easy to use by IT and end users
                                               · Automated data access and display
                                               · Complete BI package: reports, tables,key
                                                  performance indicators, and dashboards
                                               · IBM i-centric for real-time data analysis
                                               · Expert support and training
                                               · Secure data access
                                               · Green screen, Web, browser

SEQUEL--Fast, efficient & cost-effective data analysis

Click here for a FREE Information Kit!


Senior Technical Editor: Ted Holt
Technical Editor: Joe Hertvik
Contributing Technical Editors: Erwin 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

ARCAD Software:  November 20 Webinar: Unify your multi-platform release management - with IOS
Halcyon Software:  Simplify the monitoring of your ERP systems and HA solutions
Manta Technologies:  Your complete source for IBM i training


 

IT Jungle Store Top Book Picks

Easy Steps to Internet Programming for AS/400, iSeries, and System i: List Price, $49.95
The iSeries Express Web Implementer's Guide: List Price, $49.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 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
Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
Getting Started with WebSphere Express for iSeries: List Price, $49.00
Can the AS/400 Survive IBM?: List Price, $49.00
Chip Wars: List Price, $29.95


 
The Four Hundred
System for Sale Versus Service for Rent

The i 7.1s Have It; i5/OS V5R4 Extended

IBM Smart Business Moves into Italy, Solutions List Grows in U.S. and India

As I See It: High on Quack

FBI Arrests AS/400 Programmers in Madoff Scheme

Four Hundred Stuff
Security Vendors Take Aim at HITECH Act for Healthcare IT Overhaul

Raz-Lee Adds Object-Level Security to i OS Security Suite

i365 Plans Multi-Platform Backup and Recovery Based on Windows Server

Data Masking Tool from dataguise to Get DB2/400 Support

Kronos Unveils Software, New Sales Approach at Conference

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

System i PTF Guide
November 14, 2009: Volume 11, Number 46

November 7, 2009: Volume 11, Number 45

October 31, 2009: Volume 11, Number 44

October 24, 2009: Volume 11, Number 43

October 17, 2009: Volume 11, Number 42

October 10, 2009: Volume 11, Number 41

October 3, 2009: Volume 11, Number 40

TPM at The Register
IT admins: we don't need no stinkin' servers

HP: Q4 will be better than expected

Dell resells customized Cray baby super

Intel settles with AMD for $1.25bn

ASUS, MSI reveal quad InfiniBand boards

AMD unmasks Opterons of servers future

Netlist goes virtual and dense with server memory

Platform clusters Windows HPC with Linux

What do you call a flash-based super?

Cisco keeps schtum on big iron plans

HP shoots low with Lynnfield ProLiants

zPrime cost-cutting mainframeware gets traction

THIS ISSUE SPONSORED BY:

Profound Logic Software
Help/Systems
WorksRight Software


Printer Friendly Version


TABLE OF CONTENTS
File Caching in RSE

Message Received, But Not Understood

More with the WDSc Tasks View

Four Hundred Guru

BACK ISSUES




 
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