fhg
Volume 12, Number 12 -- May 2, 2012

CL Error-Handling With APIs

Published: May 2, 2012

by 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


Sponsored By
INFOR

Top Business Drivers Impacting
ERP Strategies for Distributors

Recent research indicates that wholesalers and distributors
are enacting a series of strategic actions to improve
their organization's performance
. Listen to a very candid
and engaging conversation with Aberdeen and C.H. Briggs as they discuss:

                                                 Social media's role in their business.
                                                 The accelerating pace of business.
                                                 Arguments for investing during this
                                                   challenging economy.

View the on-demand webcast.


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

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


 
The Four Hundred
IBM i 7.1 Tech Refresh Sports Live Partition Mobility

IBM Peddles Discounted, Linux-Only Power Iron

The 'New' Infor Keeps Commitment To IBM i Customers

As I See It: Spooky Action at Great Distance

Power Iron Gets New Storage And Networking

Four Hundred Stuff
TEMBO Claims Non-Disruptive Migration of IBM i Apps to SQL Engine

Infor Expands Salesforce.com Work as 1st Joint Customer Goes Live

Cilasoft Ships Authority Manager Tool for IBM i

Infor Cuts Price of ION Middleware by Over Half

VAI Announces Roadmap for IBM i-Based ERP

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

System i PTF Guide
April 28, 2012: Volume 14, Number 17

April 21, 2012: Volume 14, Number 16

April 14, 2012: Volume 14, Number 15

April 7, 2012: Volume 14, Number 14

March 24, 2012: Volume 14, Number 12

March 17, 2012: Volume 14, Number 11

TPM at The Register
Red Hat opens up OpenShift platform cloud

Cedexis helps admins fight performance anxiety

Zunicore adds GPUs to clouds

Revealed: Inside super-soaraway Pinterest's virtual data centre

Shuttle Enterprise comes home to New York

Cray revenues spike on XE6, XK6 super sales

HP spreads Superdome vPar partitions across Integrity line

Clouds rain money for Citrix in Q1

Unisys grows in Q1, swings to profit

Intel came a-knockin' for Cray super interconnects

Super Micro grows despite Xeon E5 delay, disk shortages

Intel reels in Cray's supercomputer interconnect biz

THIS ISSUE SPONSORED BY:

Infor
WorksRight Software
American Top Tools


Printer Friendly Version


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

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-2012 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement