• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Use Monitor to Trap QCMDEXC Errors

    August 23, 2002 Timothy Prickett Morgan

    Hey, Ted:

    How do I find out why QCMDEXC failed when called in an RPG program?

    — John

    Trap the error so your program doesn’t cancel. I like the new monitor and on-error op codes for this:

    D QCmdExc         pr                  extpgm('QCMDEXC') 
    D    Cmd                       256a   const             
    D    CmdLen                     15p 5 const             
                                                            
    D Cmd             s            256                      
                                                            
    D psds           sds                                    
    D   MsgID                40     46                      
    D   Msg                  91    170                      
                                                            
    C                   eval      cmd = 'dsplib br549'      
    C                   monitor                             
    C                   callp     qcmdexc (cmd: %size(cmd)) 
    C                   on-error                            
    C* call to qcmdexc failed -- do whatever 
    C                   endmon                              
    

    If you prefer, you can add an argument of *program in factor 2 of the on-error command, but it’s not necessary:

    C                   on-error  *program                  
    

    If an error occurs, check positions 40 through 46 of the program status data structure for the message ID. Look in positions 91 through 170 for the error message text.

    The monitor and on-error op codes are similar in concept to the CL Monitor Message (MONMSG) command or the Java try/catch operations. I like monitor and on-error better than the following older methods.

    If you’re not on V5, you can use the ‘old’ way to trap the failed call: the e operation extender, followed by a test for the %error function:

    C                   callp (e) qcmdexc (cmd: %size(cmd)) 
    C                   if        %error                    
    C* do whatever
    C                   endif                               
    

    Of course, there’s the ‘old old’ method: an indicator in the ‘lo’ resulting indicator position, but I won’t recommend it.

    — Ted

    Sponsored By
    ADVANCED SYSTEMS CONCEPTS

    SEQUEL meets all your iSeries and AS/400 data access needs in a single, integrated solution:

    • Windows, Web or host user interfaces

    • Convert AS/400 data into PC file formats

    • E-mail or FTP query results, reports and spool files
    • Run-time prompted queries and reports for end users

    • IF-THEN-ELSE logic in queries and reports

    • Report, form and label formatting second to none

    • Easily convert date fields, character-to-numeric, numeric-to-character and other data manipulation

    • SORT or JOIN using a calculated field

    • Quick summarization of data with Tabling function

    • Run multiple SEQUEL requests as one with the SEQUEL Scripting function

    • OLAP Business Intelligence at a fraction of the cost of comparable solutions

    Take 6 minutes to view a SEQUEL ViewPoint ScreenCam movie to see how simple Windows-based AS/400 and iSeries data access can be! In just a few short minutes, you can find out ways to make your job easier and improve data access throughout your organization. Download the ViewPoint movie here .

    For more information or a FREE trial of SEQUEL, call 847/605-1311 or visit Advanced Systems Concepts.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: mgo_rc, Volume 2, Number 64 -- August 23, 2002

    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

    Validating a User Password Timestamps and V5R1 RPG

    Leave a Reply Cancel reply

MGO Volume: 2 Issue: 64

This Issue Sponsored By

    Table of Contents

    • More on TCP/IP Printing
    • Use Monitor to Trap QCMDEXC Errors
    • Odds and Ends

    Content archive

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

    Recent Posts

    • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
    • Fresche Overhauls X-Analysis With Web UI, AI Smarts
    • Is It Time To Add The Rust Programming Language To IBM i?
    • Is IBM Going To Raise Prices On Power10 Expert Care?
    • IBM i PTF Guide, Volume 27, Number 20
    • POWERUp 2025 –Your Source For IBM i 7.6 Information
    • Maxava Consulting Services Does More Than HA/DR Project Management – A Lot More
    • Guru: Creating An SQL Stored Procedure That Returns A Result Set
    • As I See It: At Any Cost
    • IBM i PTF Guide, Volume 27, Number 19

    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