Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
Hi D,
A number of RPG operation codes can be specified with (e), eg. write(e) and update(e). You can check the manual what operations make use of this feature After the operation with the (e) you can use %error() to establish if an error occurred or not.
For SQL you can check the variable sqlcode after execution of the SQL statement.
Good luck,
Paulster
You mean something like:
begsr *pssr; if not AlreadyError; AlreadyError = *on; dump(a); endif; endsr '*cancl';
Obviously it can be made more flashy, the above example produces a program dump spoolfile, and crashes out to the calling program with a generic "it's all gone really bad" message.
And the last time I wrote one of these was back in RPGIII, over 15 years ago, so some of the syntax might need some tidying up for RPGIV /free requirements.
Yes, wrap a MONITOR/ON-ERROR/ENDMON around your entire mainline.
Monitor ;
... do EXSR, anything else, etc.
On-Error ;
... had an error
EndMon ;
Chris R
I agree with Neil - *PSSR is the global exception routine for the main procedure and it's subroutines. If you're using traditional file I/O, you may also want an INFSR() on one or more files; note that a file's INFSR() could just point to *PSSR.
A subprocedure is a separate entry point, so each would have its own *PSSR. On the other hand, subprocedures generally are smaller chunks of code, so Ringer's wrap-around Monitor block could be practical.