Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there way to trap QCMDEXC error in an RPG program other than using MONITOR

I have issued a CL command in a RPGLE program using the QCMDEXC api. Suppose the CL command throws an error. Is there any way of capturing the error without using the MONITOR.

like image 387
Kunal Roy Avatar asked Sep 12 '25 14:09

Kunal Roy


1 Answers

You can use the "e" code extender

    *  Setup QCMDEXEC
    C                   eval      cmdStr = 'CALL PGM(DMACCT001) PARM(REGIONA)'
    C                   eval      cmdLen = %len( cmdStr )
    C* call to QCMDEXC
    C                   callp(e)  command(cmdStr : cmdLen)
    C                   if        %error
    C*    ZZZ    Friendly error handler goes here
    C                   endif

D Command         PR                  ExtPgm('QCMDEXC')
D  CmdStr                    32702    const options(*varsize)
D  CmdLen                       15p 5 const
like image 133
Bidder Avatar answered Sep 14 '25 03:09

Bidder