× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I was at the recent conference in Framingham, Massachusetts and attended
Russ Popiel's session on RPG error handling.  The question came up "Can you
change the job log settings when the cancel handler is invoked?"  The answer
is Yes.  I coded up a single RPG program that demonstrates this.

h/copy qrpglesrc,stdhspec
h bnddir('QC2LE')
 * dbgview(*list)

d regExitProc     pr                  extproc('CEERTX')
d  usrExitProc                    *   procptr const
d  inpData                        *   const options(*omit)
d  fc                           12          options(*omit)

d decodeFC        pr                  extproc('CEEDCOD')
d  fcInp                        12    const
d  msgSev                       10i 0
d  msgNo                        10i 0
d  case                         10i 0
d  severity                     10i 0
d  control                       2
d  facilityID                    3
d  isInfo                        4
d  fcOut                        12          options(*omit)

d usrExitProc     pr
d  inpData                        *   const options(*omit)

d syscall         pr            10i 0 extproc('system')
d   cmd                           *   value options(*string)

d OK              c                   0
d ErrorCode       s              7A   import('_EXCP_MSGID')

d token           s             48    inz('Test data from register -
d                                          procedure')
d fc              s             12
d dummyAnswer     s              1
d msgSev          s             10i 0
d msgNo           s             10i 0
d case            s             10i 0
d severity        s             10i 0
d control         s              2
d facilityID      s              3
d isInfo          s              4

c* Change the job to log no commands
c                   if        syscall('chgjob log(0 99 *msg)') <> OK
c     'chgjob 0'    dump
c                   endif

c* Register the exit handler
c                   callp     regExitProc(%paddr('USREXITPROC'):
c                                         %addr(token):
c                                         fc)

c* Did that cause an error?
c                   callp     decodeFC(fc:
c                                      msgSev:
c                                      msgNo:
c                                      case:
c                                      severity:
c                                      control:
c                                      facilityID:
c                                      isInfo:
c                                      *omit)

c* Ask the user to kill the job stack entry
c* when you see this prompt, system request-2 to end the program
c     'endrqs'      dsply                   dummyAnswer       1

c                   seton                                        lr

p usrExitProc     b                   export
d usrExitProc     pi
d  inpData                        *   const options(*omit)

c     'Before chg'  dump

c                   if        syscall('chgjob log(4 0 *seclvl)') <> OK
c     'chgjob 1'    dump
c                   endif

p                 e

Call this program, and when it gets to the DSPLY operation, kill it with
system request or cancel the job from another session.  The exit handler
kicks in, does the "before chg dump" and then sets the job log to full
logging.  The idea being that you get an automatic post-mortem.  Of course
it'd be better to do some real work...

  --buck

"This box ROCKS!" - Related by Stephanie Joy,
  iSeries Marketing.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.