|
|
![]() |
|
|
|
|
||
|
Use Monitor to Trap QCMDEXC Errors 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
|
Editors
Contact the Editors |
|
Last Updated: 8/23/02 Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. All content published in Guild Companies publications is for informational purposes only, and accuracy of said content is not guaranteed by Guild Companies and its staff. Guild Companies and its staff do not warrant that its content is error-free. Also, Guild Companies and its staff are not responsible for the availability or content accuracy of other Web sites and services that may be linked to this Web site and service. |