Follow the rules for REXX execs: A well behaved REXX check
will adhere to all the rules for writing a REXX exec. See:
Release any system resources obtained: A REXX
check should release any resources it obtains, such as a data set,
for example, before the REXX check stops running. The REXX check must
also include logic that releases resources when an unexpected non-exception
condition, such as a time-out or CANCEL, occurs. For information about
how System REXX manages unexpected conditions, see:
The following example shows how our SYS1.SAMPLIB check, HZSSXCHK,
frees resources for an unexpected condition:
/*********************************************************************/
/* */
/* HZS_SAMPLE_REXXTSO_CHECK unexpected conditions: */
/* SYNTAX, ERROR, FAILURE, NOVALUE and HALT are specified by the */
/* SIGNAL function and receive control when an unexpected event */
/* occurs. */
/* */
/* - Report the line in error */
/* - Free the input data set if it is allocated */
/* - DISABLE the check and exit */
/* */
/*********************************************************************/
SYNTAX:
ERROR:
FAILURE:
NOVALUE:
HALT:
ERR1 = "An Error has occurred on line: "Sigl
ERR2 = sourceline(sigl)
Say Err1
Say "Line "Sigl" text: "Err2
ADDRESS TSO "FREE DSN("DataSetName")"
HZSLFMSG_REQUEST = "STOP" /* Disable the check */
HZSLFMSG_REASON = "ERROR"
HZSLFMSG_DIAG = Right(RC,16,0) /* report the decimal rc in the
HZS1002E message and the check
display detail */
HZSLFMSG_RC = HZSLFMSG()
IF HZS_PQE_DEBUG = 1 THEN
DO /* Report debug detail in REXXOUT */
SAY "PARMS: "HZS_PQE_PARMAREA
SAY "HZSLFMSG RC" HZSLFMSG_RC
SAY "HZSLFMSG RSN" HZSLFMSG_RSN
SAY "SYSTEMDIAG" HZSLFMSG_SYSTEMDIAG
END
EXIT /* The check is not performed */
Have your REXX check stop itself when
the environment is inappropriate: If your check encounters an
environmental condition that will prevent the check from returning
useful results, your check should stop itself and not run again until
environmental conditions change and your code requests it to run.
Your check should do the following to respond to an inappropriate
environment:
- Issue the HZSLFMSG function to stop itself:
HZSLFMSG_REQUEST = "STOP"
HZSLFMSG_REASON = "ENVNA"
HZSLFMSG_RC = HZSLFMSG()
- Issue an information message to describe why the check is not
running. For example, you might issue the following message to let
check users know that the environment is not appropriate for the check,
and when the check will run again:
The server is down.
When the server is available, the check will run again.
- Make sure that your product or check includes code that can detect
a change in the environment and start running the check again when
appropriate. To start running the check, issue the following HZSCHECK
service:
HZSCHECK REQUEST=RUN,CHECKOWNER=checkowner,CHECKNAME=checkname
If
the environment is still not appropriate when your code runs the check,
it can always stop itself again.
Save time, save trouble - test your check with these
commands: When you have written your check, test it with the following
commands to find some of the most common problems people make in writing
checks:
F hzsproc,UPDATE,CHECK(check_owner,check_name),DEBUG=ON
F hzsproc,UPDATE,CHECK(check_owner,check_name),PARM=parameter,REASON=reason,DATE=date
F hzsproc,DELETE,CHECK(check_owner,check_name),FORCE=YES
F hzsproc,DISPLAY,CHECK(check_owner,check_name),DETAIL
Trap internal errors, so the exec routine is not terminated
by System REXX