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. |