• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Sending Escape Messages from RPG

    July 26, 2002 Timothy Prickett Morgan

    Hey, Ted:

    I know how to use the Send Program Message (SNDPGMMSG) command to send an escape message from a CL program to its caller.

    How do I send an escape message from an RPG program?

    — Len

    Use the Send Program Message API, QMHSNDPM.

    Here’s an example:

    D SendEscMsg      pr                  extpgm('QMHSNDPM')
    D   MsgID                        7    const             
    D   MsgFile                     20    const             
    D   MsgDta                      80    const             
    D   MsgDtaLen                   10i 0 const             
    D   MsgType                     10    const             
    D   MsgQ                        10    const             
    D   MsgQNbr                     10i 0 const             
    D   MsgKey                       4                      
    D   ErrorDS                     16                      
                                                            
    D ErrorDS         ds            16                      
    D   BytesProv                   10i 0 inz(16)           
    D   BytesAvail                  10i 0                   
    D   ExceptionID                  7                      
                                                            
    D MsgDta          s             80                      
    D MsgKey          s              4                      
                                                                   
    C                   eval      MsgDta = 'Something went wrong' 
    C                   callp     SendEscMsg ('CPF9898':           
    C                               'QCPFMSG   QSYS':              
    C                               MsgDta:                        
    C                               %len(MsgDta):                  
    C                               '*ESCAPE':                     
    C                               '*':                           
    C                               2:                             
    C                               MsgKey:                        
    C                               ErrorDS)                       
    

    Notice the sixth and seventh parameters. The asterisk (*) in parameter six refers to the current call stack. The seventh parameter tells how far up the call stack to send the message. In this example, it has a value of two, because there is a program-entry-point call stack entry between the sender of the message and the calling program. In OPM programming, this parameter should have a value of one.

    For more information, see the “Send Program Message (QMHSNDPM) API ,” iSeries Information Center .

    — Ted

    Sponsored By
    TRAMENCO

    The Training and Mentoring Company (Tramenco) is dedicated to just one thing: Advancing your career by giving you the skills you need to solve real-world business problems.

    Choose from a menu of training options to fit your needs: onsite seminars, public seminars, mentoring, consulting, books, CBTs, and Web-based training.

    For more information about Tramenco’s career enhancing opportunities, call (800)421-8031 or go to www.tramenco.com.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: mgo_rc, Volume 2, Number 56 -- July 26, 2002

    Sponsored by
    ARCAD Software

    Embrace VS Code for IBM i Development

    The IBM i development landscape is evolving with modern tools that enhance efficiency and collaboration. Ready to make the move to VS Code for IBM i?

    Watch this webinar where we showcase how VS Code can serve as a powerful editor for native IBM i code and explore the essential extensions that make it possible.

    In this session, you’ll discover:

    • How ARCAD’s integration with VS Code provides deep metadata insights, allowing developers to assess the impact of their changes upfront.
    • The role of Git in enabling seamless collaboration between developers using tools like SEU, RDi, and VS Code.
    • Powerful extensions for code quality, security, impact analysis, smart build, and automated RPG conversion to Free Form.
    • How non-IBM i developers can now contribute to IBM i projects without prior knowledge of its specifics, while ensuring full control over their changes.

    The future of IBM i development is here. Let ARCAD be your guide!

    Watch the replay now!

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Did OPNQRYF Retrieve Records? Retrieving Query Definitions

    Leave a Reply Cancel reply

MGO Volume: 2 Issue: 56

This Issue Sponsored By

    Table of Contents

    • Generating a Unique Identifier
    • Restore a Single IFS Directory
    • Sending Escape Messages from RPG

    Content archive

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

    Recent Posts

    • 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
    • IBM Unveils Manzan, A New Open Source Event Monitor For IBM i
    • Say Goodbye To Downtime: Update Your Database Without Taking Your Business Offline
    • i-Rays Brings Observability To IBM i Performance Problems
    • Another Non-TR “Technology Refresh” Happens With IBM i TR6
    • IBM i PTF Guide, Volume 27, Number 18

    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