• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Message Received, But Not Understood

    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

    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

    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

    Vegas Casino Doesn’t Gamble with Software from Agilysys IBM Slashes Power Systems Memory Prices

    Leave a Reply Cancel reply

Volume 9, Number 36 -- November 18, 2009
THIS ISSUE SPONSORED BY:

Profound Logic Software
Help/Systems
WorksRight Software

Table of Contents

  • File Caching in RSE
  • Message Received, But Not Understood
  • More with the WDSc Tasks View

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