|
The MONITOR operation sets up an event handler for a monitored group of statements. This event handler works similar to a MONMSG command in CL. It establishes a block of code (group of RPG statements) that are run when an error occurs within the monitored group. To set up a monitored group, you type the MONITOR operation code, then follow it with the statements for which the monitoring applies. Then, after the final statement in the monitor group, type the ON-ERROR operation with the RPG Status Code error ID in Factor 2. With ON-ERROR - Set Up Event Monitor, you can specify one or more status codes with the ON-ERROR operation. This is similar to using a MONMSG command in CL with multiple message IDs specified. As always in RPG IV, you separate multiple status code with a colon. There are three identifiers that you can use to create a more generic handler. In place of a specific status code, specify *PROGRAM to indicate that any program status code (i.e., those in the range of 1000 to 9999) are monitored, or *FILE to indicate that any file-related status code (i.e., those in the range of 100 to 999) are monitored. Optionally, you can specify *ALL for the status code that, obviously, monitors for any status code to occur. For example: 0010 C MONITOR 0020 C EXFMT EditCust 0030 C if CustNo > 0 0040 C Write CustMast 0050 C endif 0060 C ON-ERROR 01021 0070 C CallP DupKeyDetected 0080 C ON-ERROR *FILE 0090 C CallP DupKeyDetected 0100 C ENDMON Hope that helps, Peter Vidal Pall Aeropower Corp. SR Programmer Analyst WWW.Pall.com "A good player makes himself look good; a great player makes the team look good." Author unknown
As an Amazon Associate we earn from qualifying purchases.
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.