SETMAX – Manipulate the maximum return code

Use the SETMAX command to modify the maximum return code and maximum response code, at any point in the Workload Automation Programming Language command sequence.

SETMAX POLICY(<in_rc1>=<out_rc1>,<in_rc2>=<out_rc2>,...,
                <in_rcn>=<out_rcn>,<catch_all>)
       [SET(MAX_RC|MAX_RESP|BOTH)]

The command takes the current maximum return code, or maximum response code, or both, and use the POLICY keyword, looking for a match on the left side of each expression (in_rc). If a match is found, it sets the new maximum to the right side of the expression (out_rc).

If no match is found it, it sets the return code to the specified catch_all return code. If you omit to supply a catch all return code, and there is no match, the return code remains unchanged.

This command can influence maximum values: the maximum return code and maximum response code. The maximum response code is a special case of return code that is set by commands such as LISTSTAT, which sets the return codes to communicate the status of an HCL Workload Automation for Z object to other steps outside Workload Automation Programming Language. However, the number of variants of return code to do this usually exceeds the critical return code (set by OPTIONS STOPRC), which would flush the remaining Workload Automation Programming Language processing. To avoid this, commands of this type set a response code, which is returned by Workload Automation Programming Language when it completes, if it is higher than the maximum return code.

To specify which maximum code the SETMAX command will affect, use the SET keyword with one of the following arguments:
MAX_RC
Default. Compares the POLICY against the current maximum return code, and modifies the maximum return code if a match is made within the POLICY. It also sets the return code of the SETMAX command to the same value.
MAX_RESP
Compares the POLICY against the current maximum response code, and modifies the maximum response code if a match is made within the POLICY. It does not set the return code of the SETMAX command.
BOTH
Compares with the higher of the current maximum return code and maximum response code. It modifies both if a match is found within the POLICY. It also sets the return code of the SETMAX command to the same value.
In the following example, the result of a LIST statement is reversed. If something is found, typically you would get RC=0 and if not found you would get RC=4. The SETMAX statement reverses that, so you can have a situation where the “good outcome” is for something to not be there (RC=0) and the “bad outcome” is if it is found (RC=4).
05/28 12.55.11 EQQI200I LIST CPOPCOM ADID(TWSCDAILYPLAN) OPNO(010)
                        IA(0805281300)                            
05/28 12.55.12 EQQI299I Statement completed - RC=4                
05/28 12.55.13 EQQI200I SETMAX POLICY(0=4,4=0)                    
05/28 12.55.13 EQQI122A Maximum return code 4 changed to 0        
05/28 12.55.13 EQQI299I Statement completed - RC=0  
Another use of this would be to consolidate unexpected return codes. Workload Automation Programming Language returns only 0, 4, 8, 12, and 16, but the HCL Workload Automation for Z PIF could return other higher return codes (for example, RC=700 for an uninitialized session). In the following example, return codes 0, 4, 8, 12, and 16 remain unchanged, but if any other return code is found it is set to 20.
SETMAX POLICY(0=0,4=4,8=8,12=12,16=16,20)
The following example shows how you can also influence a response code set by LISTSTAT. This would set the maximum response code from any previous LISTSTAT commands to zero, but not alter the maximum return code as set by other processes:
SETMAX POLICY(0) SET(MAX_RESP) 
Note: The default value of the SETMAX SET keyword can be influenced by OPTIONS SETMAX.