• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • CL Error-Handling With APIs

    May 2, 2012 Ted Holt

    Note: The code accompanying this article is available for download here.

    I had the great pleasure of meeting Brian Rusch in Milwaukee last month, when I spoke to the Wisconsin Midrange Computer Professionals Association (WMCPA). Brian told me about the method his shop uses to handle CL program exceptions. I’d like to share it with you.

    IBM has established an architecture for exception handling. When a program exception occurs, the system may send one or more diagnostic messages that give information about the error. The system does send an escape message, which summarizes the problem and cancels the program.

    Brian’s method takes advantage of this architecture. Brian has written command interfaces to two IBM-supplied APIs: Move Program Messages (QMHMOVPM); and Resend Escape Message (QMHRSNEM). His command MOVPGMMSG runs QMHMOVPM in order to forward the diagnostic messages to the caller. Brian’s RSNESCMSG command uses API QMHRSNEM to resend the escape message to the caller and cancel the failing program. His exception handling is easily handled with the following code:

    MONMSG CPF0000 EXEC(GOTO ABEND)
    . . . more code . . .
       RETURN
    ABEND:
       MOVPGMMSG  MSGTYPE(*DIAG)
       RSNESCMSG
    

    In 2004, I published a template with roots in the System/38. If you compare this code to the code I published eight years ago, you’ll see that Brian’s code is much shorter and simpler than mine. There are no loops, and five of the variables in my code are not needed in his.

    My hat is off to Brian Rusch for making simple interfaces for two messy APIs. The downloadable source code files contain not only Brian’s command source, but two example programs you can play with. One uses his commands. The other uses a slightly modified version of the template I use in my shop.

    RELATED STORY

    Proper CL Error-Handling



                         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
    Manta Technologies

    The Leader in IBM i Education!
    Need training on anything i?
    Manta is all you need.

    During the month of May, when you purchase a license for the Free-Form RPG Programming series for any term (one, two, or three years) and any user license level, and you will get the equivalent license for the Coding Free-Form RPG course for FREE.

    130 courses and competency exams on:
    · IBM i operations
    · System Management and Security
    · IBM i Programming Tools
    · Programming in RPG, COBOL, CL, Java
    · Web Development
    · SQL, DB2, Query

    Product features:
    · Runs in every popular browser
    · Available 24/7/365
    · Free Student Reference Guides
    · Free Student Administration
    · Concurrent User License
    · Built-In IBM i Simulator

    You can download our 200-page catalog and take sample sessions at MantaTech.com.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Tembo Application Generation:  Reclaim your heritage with ADSERO OPTIMA!
    Tributary Systems:  Storage Director, a disk-to-disk-to-tape solution. Download the case study.
    COMMON:  Join us at the 2012 Conference & Expo, May 6 - 9 in Anaheim, CA

    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

    Island Pacific Completes ERP Upgrade for Clothing Retailer Apps And IBM i Evangelism

    Leave a Reply Cancel reply

Volume 12, Number 12 -- May 2, 2012
THIS ISSUE SPONSORED BY:

Infor
WorksRight Software
American Top Tools

Table of Contents

  • CL Error-Handling With APIs
  • How Do I Format Date Literals? Let Me Count The Ways
  • Admin Alert: Secrets Of The IBM i IPL Parameters

Content archive

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

Recent Posts

  • COMMON Set for First Annual Conference in Three Years
  • API Operations Management for Safe, Powerful, and High Performance APIs
  • What’s New in IBM i Services and Networking
  • Four Hundred Monitor, May 18
  • IBM i PTF Guide, Volume 24, Number 20
  • IBM i 7.3 TR12: The Non-TR Tech Refresh
  • IBM i Integration Elevates Operational Query and Analytics
  • Simplified IBM i Stack Bundling Ahead Of Subscription Pricing
  • More Price Hikes From IBM, Now For High End Storage
  • Big Blue Readies Power10 And IBM i 7.5 Training for Partners

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 © 2022 IT Jungle

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.