To learn how to use the watch for event function with an exit program,
read this scenario.
You have a MYCLNUP program that you run whenever
you want to free up storage space on your system. You usually run this program
when message CPF0907 (Serious storage condition might exist)
is sent to the system operator message queue (QSYSOPR).
You use the
watch for event function to automatically run your clean up program when the
amount of available storage in the system auxiliary storage pool has reached
the threshold value. Your user exit program also performs some special actions
when the available storage is less than 5 percent.
To run MYCLNUP when message CPF0907 enters
the specified message queue, follow these steps:
- Start a watch session:
- At the command line, type STRWCH and press F4.
- For the Session ID prompt, specify a meaningful
session identifier, such as mycleanup.
- For the Watch program parameter, specify MYWCHPGM,
and type MYLIB for the Watch program Library prompt.
MYWCHPGM is the exit program to be called when the watched for event occurs.
See Exit program for watch for event scenario.
- For the Watch for message, Message identifier prompt,
type CPF0907.
- For the Watched message queue, Message
queue prompt, type *SYSOPR. This ensures that your watch
exit program is called when the CPF0907 message is sent to the system
operator message queue.
- Verify that the watch session started:
- At the command line, type WRKWCH and press F4.
- For the Watch prompt, type *STRWCH.
- Check to see that the MYCLEANUP session is listed under the STRWCH type.
After the CPF0907 message is sent to the system operator
message queue, the MYWCHPGM program in MYLIB library is called. This program
can call your MYCLNUP program and do any other function you need by customizing
the exit program.
- When you do not need your watch session anymore, end it:
- At the command line, type ENDWCH and press F4.
- For the Session ID prompt, specify mycleanup.
- Verify that the watch session ended:
- At the command line, type WRKWCH and press F4.
- For the Watch prompt, type *STRWCH.
- Check to see that the MYCLEANUP session is not listed anymore.
Note: You
can also type DSPMSG MSGQ(*SYSOPR) to verify that the watch session
has ended. You should see the CPI3999 message, which indicates that
the MYCLEANUP watch session was ended because of reason code 08. Reason code
08 indicates that the End Watch (ENDWCH) command or End Watch (QSCEWCH) API
was issued.