Volume 7, Number 17 -- May 2, 2007

Monitor for Specific Messages in RPG

Published: May 2, 2007

Hey, Ted:

I have a CL program that calls another CL program and monitors for specific escape messages. No big deal. I put multiple Monitor Message (MONMSG) commands after the CALL. Suppose I want to call the second CL program from an RPG program. How do I monitor for the different errors?


OK, Ray, let's set this up for the readers. Let's suppose your program, which we'll call SOMEPGM, can return escape messages MYM2101 and MYM2105. A CL caller monitors for those messages like this:

CALL       PGM(SOMEPGM) PARM(&whatever) 
/* do something */
/* do something else */

In RPG programs, use the E extender when calling the program in order to trap the error. Then check positions 40 through 46 of the program status data structure to see which error you got. Here's the code in fixed-format syntax.

D psds           sds              
D  MsgID                 40     46
D  ExceptData            91    170

C                   call(e)   'SOMEPGM'        
C                   parm                    whatever
C                   if        %error            
C                   select                      
C                   when      MsgID = 'MYM2101' 
C************* do something 
C                   when      MsgID = 'MYM2105' 
C************* do something else
C                   endsl                       

Here is the same example in free-format RPG.

D psds           sds              
D  MsgID                 40     46
D  ExceptData            91    170

D SomePgm        pr                  extpgm('SOMEPGM')
D   Whatever                     1a                     

     callp(e) SOMEPGM (whatever);   
     if %error;                    
           when MsgID = 'MYM2101'; 
              // do something
           when MsgID = 'MYM2105'; 
              // do something else

In case you're interested, the text of the error message is also in the program status data structure. You'll find it in positions 91 through 170. You can often help the user by writing this message text to an error subfile record or to a printed report.


                     Post this story to del.icio.us
               Post this story to Digg
    Post this story to Slashdot

Sponsored By

SEQUEL can be used for
virtually ALL business intelligence functions
on the System i, including:

                                                    · Executive Dashboards
                                                    · Graphical Query & Reporting
                                                    · Drill-Down Data Analysis
                                                    · Multi-Platform Database Support
                                                    · E-Mail Report and File Distribution
                                                    · Secure Web Access

SEQUEL is the single solution for all
your business intelligence needs.


Senior Technical Editor: Ted Holt
Technical Editors: Howard Arner, Joe Hertvik, Shannon O'Donnell, Kevin Vandever
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Brian Kelly, Marc Logemann, David Morris
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

COMMON:  Join us at the Annual 2008 conference, March 30 - April 3, in Nashville, Tennessee
Seagull Software:  Web-enable your System i apps with LegaSuite GUI
VAULT400:  Securely archive data with Instant Back-Up & 24x7 Recovery

IT Jungle Store Top Book Picks

The System i Pocket RPG & RPG IV Guide: List Price, $69.95
The iSeries Pocket Database Guide: List Price, $59.00
The iSeries Pocket Developers' 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
iSeries Express Web Implementer's Guide: List Price, $59.00
Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95
Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
Getting Started with WebSphere Express for iSeries: List Price, $49.00
WebFacing Application Design and Development Guide: List Price, $55.00
Can the AS/400 Survive IBM?: List Price, $49.00
The All-Everything Machine: List Price, $29.95
Chip Wars: List Price, $29.95


The Four Hundred
The i5 515 and 525: IBM's Competitive Analysis

More Details Emerge on IBM's Upcoming Power6 Server Launch

How to Build a Less Expensive i5 Developer Workstation

Mad Dog 21/21: Hearts and Minds

The Linux Beacon
Startup 3Leaf Systems Looks to Shake Up Server Virtualization

Sun's X64-Based Streaming Server Runs on Linux

More Details Emerge on IBM's Upcoming Power6 Server Launch

Mad Dog 21/21: Hearts and Minds

Four Hundred Stuff
MySQL Database Getting Closer Ties to the System i

BCD Bringing PHP Generation to WebSmart IDE

Quadrant Updates Forms Package, Content Management System

IBM Rolls Out LTO 4 Tape Drives and Libraries

Big Iron
Merrill Lynch Takes a Closer Look at IBM's Server Sales in Q1

Top Mainframe Stories From Around the Web

Chats, Webinars, Seminars, Shows, and Other Happenings

System i PTF Guide
April 28, 2007: Volume 9, Number 17

April 21, 2007: Volume 9, Number 16

April 14, 2007: Volume 9, Number 15

April 7, 2007: Volume 9, Number 14

March 31, 2007: Volume 9, Number 13

March 24, 2007: Volume 9, Number 12

The Windows Observer
Microsoft and SAP Talk Duet Roadmap, Tap HP for Appliance

No Patch Yet for DNS Flaw

Round Two: Intel's Fortunes Rise, and AMD's Fall

Intel Details Future 45 Nanometer Chip Plans from Beijing

The Unix Guardian
Computer Trade Group Alleges Unfair Trading Practices at Sun

HP Chases Data Warehousing Dollars with Tweaked NonStop Servers

Sun Grows Sales and Profits Despite Product Transitions

As I See It: Induced Labor

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


Vision Solutions
WorksRight Software

Monitor for Specific Messages in RPG

Overcome the Page Control Limitations of iSeries Access Printer Emulation Sessions

Admin Alert: Dealing with i5 Critical Storage Errors, Part 2

Four Hundred Guru


From the IT Jungle Forums
Specific Record Range (CL)

Can a program be written to pull data from the network?

Adopted Authority....

PASE application terminates when session is closed

User profile for webserver instances

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

Privacy Statement