• 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
    DRV Tech

    Get More Out of Your IBM i

    With soaring costs, operational data is more critical than ever. IBM shops need faster, easier ways to distribute IBM applications-based data to users more efficiently, no matter where they are.

    The Problem:

    For Users, IBM Data Can Be Difficult to Get To

    IBM Applications generate reports as spooled files, originally designed to be printed. Often those reports are packed together with so much data it makes them difficult to read. Add to that hardcopy is a pain to distribute. User-friendly formats like Excel and PDF are better, offering sorting, searching, and easy portability but getting IBM reports into these formats can be tricky without the right tools.

    The Solution:

    IBM i Reports can easily be converted to easy to read and share formats like Excel and PDF and Delivered by Email

    Converting IBM i, iSeries, and AS400 reports into Excel and PDF is now a lot easier with SpoolFlex software by DRV Tech.  If you or your users are still doing this manually, think how much time is wasted dragging and reformatting to make a report readable. How much time would be saved if they were automatically formatted correctly and delivered to one or multiple recipients.

    SpoolFlex converts spooled files to Excel and PDF, automatically emailing them, and saving copies to network shared folders. SpoolFlex converts complex reports to Excel, removing unwanted headers, splitting large reports out for individual recipients, and delivering to users whether they are at the office or working from home.

    Watch our 2-minute video and see DRV’s powerful SpoolFlex software can solve your file conversion challenges.

    Watch Video

    DRV Tech

    www.drvtech.com

    866.378.3366

    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