NOHANDLE
The CICS NOHANDLE statement is an option used in CICS commands to disable automatic error handling for that specific command. Normally, when an error occurs in a CICS program, CICS either transfers control to an error-handling routine (HANDLE CONDITION) or abends the transaction. However, when NOHANDLE is used, CICS does not transfer control automatically to an error routine. Instead, the program must check the response codes manually.
When NOHANDLE is coded, it only affects the command on which it is used and does not impact other commands.
Key Features -
- Prevents CICS from invoking HANDLE CONDITION or default error handling.
- Forces the programmer to check RESP codes explicitly.
- Used within individual CICS commands (not a standalone statement).
- Overrides previously defined HANDLE CONDITION statements for that command.
Syntax -
EXEC CICS <command>
[NOHANDLE]
RESP(response-field)
END-EXEC.
- NOHANDLE - Specifies the CICS condition to be ignored (e.g., NOTFND, DUPKEY).
- RESP(response-field) - Stores the response code returned by the command.
Short Examples -
Scenario1 - Using NOHANDLE in a CICS READ Command
...
PROCEDURE DIVISION.
...
EXEC CICS READ
DATASET('CUSTFILE')
INTO(WS-DATA)
NOHANDLE
RESP(WS-RESP)
END-EXEC.
IF WS-RESP NOT = 0 THEN
...
END-IF.
If READ fails, CICS does not transfer control to an error routine. Instead, the program checks RESP (WS-RESP) manually. If the record is not found (DFHRESP(NOTFND)), a custom error message is displayed.
Scenario2 - Using NOHANDLE in a CICS WRITE Command
...
PROCEDURE DIVISION.
EXEC CICS WRITE
DATASET('CUSTFILE')
FROM(WS-RECORD)
NOHANDLE
RESP(WS-RESP)
END-EXEC.
IF WS-RESP NOT = 0 THEN
...
END-IF.
NOHANDLE is used to prevent automatic error handling. The program manually checks RESP (WS-RESP).