Using the TRAP command to obtain information about conditions in the system when an error occurs

The TRAP command allows you to determine conditions in the system if an error occurs. You can test for all error codes in all modules, for a specific error code in all modules, for all error codes in a specific module, or for a specific error code in a specific module. When an error occurs, you can have DFSMShsm abnormally end, log the error, or take a SNAP dump. You can control whether the abnormal end or SNAP dump occurs always, never, or once.
Note: TRAP is not supported in the secondary address space.
To trap all error codes in all modules and cause an abnormal end for every error, issue the following command:
TRAP ALL ABEND(ALWAYS)
To trap all error codes in all modules and cause an abnormal end once, issue the following command:
TRAP ALL ABEND(ONCE)
To trap a specific error code in a specific module and log the error, issue the following command:
TRAP module errorcode LOG

When the error indicated by errorcode occurs in the module indicated by module, an entry is written in the DFSMShsm log.

To cause a SNAP dump every time a specific error code occurs in a specific module, issue the following command:
TRAP module errorcode SNAP(ALWAYS)

Related reading

For more information about the TRAP command, see z/OS DFSMShsm Diagnosis.