• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • RPG Subprocedure Error-Handling with APIs

    July 11, 2012 Ted Holt

    In the May 2, 2012, edition of this august publication, I shared how Brian Rusch’s shop uses an API to forward escape messages up the call stack in CL programs. The Resend Escape Message (QMHRSNEM) API works just as well in RPG subprocedures. Here’s how it’s easily done.

    First, you need a prototype for QMHRSNEM, and you must define the first two parameters.

    D ResendEscapeMsg...
    D                 pr                  extpgm('QMHRSNEM')
    D   MessageKey                   4a   const
    D   ErrorCode                   10i 0 const
    

    You can define the remaining parameters if you want, but make sure you mark them OPTIONS(*NOPASS). If you like, place the prototype in a copybook source member.

    In your subprocedure, place the “meat” under a MONITOR operation. Place the call to QHMRSNEM in the corresponding ON-ERROR group, like this:

    D ResendEscapeMsg...
    D                 pr                  extpgm('QMHRSNEM')
    D   MessageKey                   4a   const
    D   ErrorCode                   10i 0 const
    
     * ====================================================================
     * xxxx - description and other documentation
     * ====================================================================
    P <xxxxxxxxxxxx>  b                   export
    D                 pi
     //////////////////////// D specs for parameters
     *** locals
     //////////////////////// D specs for local data
     /free
         monitor;
            ... do something
            ... do something else
         on-error;
            ResendEscapeMsg (*blanks: *zero);
         endmon;
         return;
     /end-free
    P                 e
    

    Notice the two arguments supplied to ResendEscapeMessage: blanks and zeros. You’ll never need any other values.

    The result is that the system catches any fatal error and sends it along to the calling procedure.

    I like the way this works. Give it a try.

    RELATED STORY

    CL Error-Handling With APIs



                         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
    Maxava

    Migrate IBM i with Confidence

    Tired of costly and risky migrations? Maxava Migrate Live minimizes disruption with seamless transitions. Upgrading to Power10 or cloud hosted system, Maxava has you covered!

    Learn More

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Maxava:  When disaster strikes, you're in control with Maxava HA Enterprise+
    looksoftware:  FREE Webcast: Leverage mobile technology with IBM i. EMEA: June 26, U.S.: June 27
    T.L. Ashford:  Barcode400 Labeling Software makes it easy to design and print labels in minutes

    IT Jungle Store Top Book Picks

    BACK IN STOCK: Easy Steps to Internet Programming for System i: List Price, $49.95

    The iSeries Express Web Implementer's Guide: List Price, $49.95
    The iSeries Pocket Database Guide: List Price, $59
    The iSeries Pocket SQL Guide: List Price, $59
    The iSeries Pocket WebFacing Primer: List Price, $39
    Migrating to WebSphere Express for iSeries: List Price, $49
    Getting Started with WebSphere Express for iSeries: List Price, $49
    The All-Everything Operating System: List Price, $35
    The Best Joomla! Tutorial Ever!: List Price, $19.95

    Tomcat 7 Support Added to mrc’s m-Power Dev Tool Windows On The (2012 And Cloudy) World

    Leave a Reply Cancel reply

Volume 12, Number 18 -- July 11, 2012
THIS ISSUE SPONSORED BY:

WorksRight Software
Help/Systems
Tembo Application Generation

Table of Contents

  • DB2 For i XMLTABLE, Part 2: Using Namespaces And IFS XML Files
  • RPG Subprocedure Error-Handling with APIs
  • Admin Alert: Making Run the Same Run the Same On IBM i Access 7.1 On Windows 7

Content archive

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

Recent Posts

  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24
  • Big Blue Raises IBM i License Transfer Fees, Other Prices
  • Keep The IBM i Youth Movement Going With More Training, Better Tools
  • Remain Begins Migrating DevOps Tools To VS Code
  • IBM Readies LTO-10 Tape Drives And Libraries
  • IBM i PTF Guide, Volume 27, Number 23

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