• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Using APIs to Send Impromptu Messages

    October 9, 2002 Ted Holt

    Hey, Ted:

    I would like to use the error message APIs QMHRMVPM and QMHSNDPM in an RPG IV program to send messages to an error-message subfile.

    I do not want to have to define the messages in a message file. I would prefer to use constant definitions from within my RPG program. Is this possible?

    I’ve searched written manuals and have not yet found a way to do this.

    — Russell

    Any message that is not sent as an *ESCAPE, *STATUS, or *NOTIFY message can be sent as an impromptu message, Russell. Here’s a short program you can play with. The display file is the JKL001D file from the March 29, 2002, “Odds and Ends” column.

    A                                      DSPSIZ(24 80 *DS3)
    A          R FORMAT01
    A                                      CA03(03)
    A                                      OVERLAY
    A                                  1 31'Generate Some Report'
    A                                  1 72DATE
    A                                      EDTCDE(Y)
    A                                  2 72TIME
    A                                  5  8'Enter range of dates in MMDDYY for-
    A                                      mat. You may leave ending date'
    A                                  6  8'blank if the report is to be run f-
    A                                      or only one day.'
    A                                  8  8'Beginning date ...................-
    A                                      ...........:'
    A            SBGNDATE       6Y 0B  8 55EDTCDE(4)
    A                                  9  8'Ending date ......................-
    A                                      ...........:'
    A            SENDDATE       6Y 0B  9 55EDTCDE(4)
    A                                 22  6'F3=Cancel request'
    A                                 22 27'Enter=Generate report'
    A
    A          R MSGSFL                    SFL
    A                                      SFLMSGRCD(24)
    A            MSGKEY                    SFLMSGKEY
    A            PGMNAM                    SFLPGMQ
    A
    A          R MSGCTL                    SFLCTL(MSGSFL)
    A                                      SFLSIZ(0010)
    A                                      SFLPAG(0001)
    A                                      OVERLAY
    A                                      SFLDSP
    A                                      SFLDSPCTL
    A                                      SFLINZ
    A N87                                  SFLEND
    A            PGMNAM                    SFLPGMQ(10)
    

    Notice the SFLPGMQ keywords in both the subfile and subfile control formats. I attached the field name PGMNAM to both of them. (This is a habit from my RPG III days, when the maximum allowable length of variable names was six characters.) This variable gets its value from the program status data structure of the RPG program.

    Here’s the RPG source code. I compiled it with Create Bound RPG Program (CRTBNDRPG) command to run in the default activation group. I only included one test for an error. In a production environment, there would be more, of course.

    FJKL001D   cf   e             workstn
    
    D Error           s               n
    
    D ErrorDS         ds            16
    D   BytesProv                   10i 0 inz(%size(ErrorDS))
    D   BytesAvail                  10i 0
    D   ExceptionID                  7
    
    D                sds
    D  PgmNam           *proc
    D
    D Msg             s             78
    D
    D SendMsg         pr                  extpgm('QMHSNDPM')
    D   MsgID                        7a   const
    D   MsgF                        20a   const
    D   MsgData                     30a   const
    D   MsgDataLen                  10i 0 const
    D   MsgType                     10a   const
    D   CallStackEnt                10a   const
    D   CallStackCtr                10i 0 const
    D   MsgKey                       4a   const
    D   Error                             like(ErrorDS)
    
    D ClrMsgQ         pr                  extpgm('QMHRMVPM')
    D   MsgQueue                   276a   const
    D   CallStack                   10i 0 const
    D   MsgKey                       4a   const
    D   MsgRmv                      10a   const
    D   Error                             like(ErrorDS)
    
     /free
       dow '0' = '0';
         exfmt format01;
         // clear msg subfile
         callp  ClrMsgQ ('*': *zero: *blanks: '*ALL': ErrorDS);
         if *in03;
            leave;
         endif;
         // ++++++++ calcs to verify data go here ++++++++
         error = *off;
         if (sbgndate = *zero);
            error = *on;
            msg = 'Beginning date must not be blank.';
         endif;
         // ----------------------------------------------
         if not error;
            leave;
         endif;
         callp  SendMsg (*blanks: *blanks :
                Msg : %size(Msg):
                '*INFO': '*':
                 0: *blanks: ErrorDS);
         write msgctl;
       enddo;
    
      if not *in03;
        // do what needs to be done
      endif;
    
      *inlr = *on;
     /end-free
    

    I hope this helps.

    — Ted

    Sponsored By
    inFORM DECISIONS

    ELIMINATE THE COSTS OF PRE-PRINTED FORMS, LABOR AND POSTAGE WITH
    inFORM Decisions iDocs™ ‘Suite’

    iSeries based e-Forms, e-Checks, e-Mail, e-FAX, and Document Retrieval from the Web are available as individual modules or as a complete e-Document processing ‘Suite’.

    Click to Download the Complete Suite or Individual Modules today
    www.inFORMDecisions.com

    or call (800) 858-5544

     

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: 2002, mgo_rc, Number 77 -- October 9, Volume 2

    Sponsored by
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    David’s Choice for Java Error Logging Reader Feedback and Insights: Dynamic Result Field in Query/400

    Leave a Reply Cancel reply

MGO Volume: 2 Issue: 77

This Issue Sponsored By

    Table of Contents

    • Reader Feedback and Insights: QTEMP and the Library List
    • FTP and Save Files, Yet Again!
    • Using APIs to Send Impromptu Messages

    Content archive

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

    Recent Posts

    • 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
    • Will The Turbulent Economy Downdraft IBM Systems Or Lift It?
    • How IBM Improved The Database With IBM i 7.6
    • Rocket Celebrates 35th Anniversary As Private Equity Owner Ponders Sale
    • 50 Acres And A Humanoid Robot With An AI Avatar
    • IBM i PTF Guide, Volume 27, Number 17

    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