Handling Errors

The NACT04 program is a general-purpose error routine. It isn’t invoked directly by any transaction, but instead receives control from programs NACT01, NACT02, and NACT03 when they meet a condition from which they cannot recover.

The program sends a screen to the terminal user (see Figure 5-2) with a text description of the problem and a request to report it. The text is based on the CICS command that failed and the particular error that occurred on it. The name of the transaction and the program (and, if applicable, the file) involved are also shown. The command, error type, and program name are passed to the NACT04 program from the program that transferred control to it; other items come from the CICS EXEC Interface Block (EIB). The EIB is a CICS control block associated with a task, containing information accessible to the application program. We’ll look at it in more detail in The EXEC Interface Block (EIB) in Chapter 11.

After writing the screen, the program abends, so that any updates to recoverable resources performed in the half-completed transaction get backed out.

You’ll see the NACT04 program in action in the Execution Diagnostic Facility (EDF) session described in Chapter 16.

An example of a transaction error screen

Figure 5-2. An example of a transaction error screen

As you saw in Figure 4-3, the NACT04 program begins by issuing an EXEC CICS ASSIGN command. This command obtains information from CICS about the environment and the problem. This helps you diagnose a problem and determine whether the NACT04 program was entered using an EXEC CICS ABEND command or whether the application program passed control to it using an EXEC CICS XCTL command or called it using an EXEC CICS LINK command. Alternatively, it could have been called by a COBOL dynamic CALL, although this is not used in the sample application program.

The CICS ASSIGN command requests values from outside the application program’s local environment. The syntax is as follows:

EXEC CICS ASSIGN ABCODE(data-area)
                 ABPROGRAM(data-area)
                 ASRAINTRPT(data-area)
                 ASRAKEY(cvda)
                 ASRAPSW(data-area)
                 ASRAREGS(data-area)
                 ASRASPC(cvda)
                 ASRASTG(cvda)
                 FCI(data-area)
                 INVOKINGPROG(data-area)
                 NETNAME(data-area)
                 PROGRAM(data-area)
                 RETURNPROG(data-area)
                 STARTCODE(data-area)
                 TERMCODE(data-area)
                 RESP(data-area) RESP2(data-area)
END-EXEC

The options in this command are:

ABCODE(data-area)

Returns a four-character abend code. (Abend codes are documented in the CICS Messages and Codes manual that is on the CD-ROM). If an abend has not occurred, the variable is set to blanks.

ABPROGRAM(data-area)

Returns an eight-character name of the failing program for the latest abend. If the abend originally occurred in a DPL server program running in a remote system, ABPROGRAM returns the DPL server program name.

This field is set to binary zeros if it is not possible to determine the failing program at the time of the abend.

ASRAINTRPT(data-area)

Returns an eight-character program status word (PSW) containing interrupt information at the point when the latest abend with a code of ASRA, ASRB, ASRD, or AICA occurred.

The field contains binary zeros if no ASRA, ASRB, ASRD, or AICA abend occurred during the execution of the issuing transaction, or if the abend originally occurred in a remote DPL server program.

ASRAKEY(cvda)

Returns the execution key at the time of the last ASRA, ASRB, AICA, or AEYD, abend, if any. CVDA values are:

ASRAPSW(data-area)

Returns an eight-character program status word (PSW) at the point when the latest abend with a code of ASRA, ASRB, ASRD, or AICA occurred.

The field contains binary zeros if no ASRA, ASRB, ASRD, or AICA abend occurred during the execution of the issuing transaction, or if the abend originally occurred in a remote DPL server program.

ASRAREGS(data-area)

Returns the contents of general registers 0–15 at the point when the latest ASRA, ASRB, ASRD, or AICA abend occurred.

The contents of the registers are returned in the data area (64 bytes long) in the order 0, 1…, 14, 15.

ASRASPC(cvda)

Returns the type of space in control at the time of the last ASRA, ASRB, AICA, or AEYD abend, if any. The CVDA values on the ASRASPC option are:

ASRASTG(cvda)

Returns the type of storage being addressed at the time of the last ASRA or AEYD abend, if any. The CVDA values are:

FCI(data-area)

Returns a one-byte facility control indicator. This indicates the type of facility associated with the transaction; for example, X'01’ indicates a terminal or logical unit. A value is always returned.

INVOKINGPROG(data-area)

Returns the eight-character name of the application program that used the LINK or XCTL command to link or transfer control to the current program. If you issue the ASSIGN INVOKINGPROG command:

NETNAME(data-area)

Returns the eight-character name of the logical unit in the VTAM network. If the task is not initiated from a terminal, INVREQ occurs. If the principal facility is not a local terminal, CICS returns the netname of the remote terminal. If this command was issued by a user transaction that was started by a bridged-to transaction, the value returned is the termid of the Bridge Facility.

Program(data-area)

Returns an eight-character name of the currently running program.

RETURNPROG(data-area)

Returns the eight-character name of the program to which control is to be returned when the current program has finished executing. The values returned depend on how the current program was given control, as follows:

STARTCODE(data-area)

Returns a two-byte indicator showing how the transaction issuing the request was started. It can have the following values:

Code

Transaction Start By

D

A distributed program link (DPL) request that did not specify the SYNCONRETURN option. The task cannot issue I/O requests against its principal facility, nor can it issue any syncpoint requests.

DS

A distributed program link (DPL) request, as in code D, that did specify the SYNCONRETURN option. The task cannot issue I/O requests against its principal facility, but can issue syncpoint requests.

QD

Transient data trigger level.

S

START command without data.

SD

START command with data.

SZ

FEPI START command.

TD

Terminal input or permanent transid.

U

User attached task.

TERMCODE(data-area)

Returns a two-byte code giving the type and model number of the terminal associated with the task. The first byte is a code identifying the terminal type, derived from the terminal resource definition. This is the DEVICE attribute (described in the CICS Resource Definition Guide). The second byte is a single-character model number as specified in the TERMMODEL attribute.

Having determined how the error handling program received control (through the LINK or XCTL command), the EXEC CICS INQUIRE PROGRAM is used in two ways: one to confirm that this was the program where the error occurred, and secondly, if it is not, then to browse the other programs to see if it can find the culprit.

The syntax of the EXEC CICS INQUIRE PROGRAM is as follows:

EXEC CICS INQUIRE PROGRAM(name)
                  LOADPOINT(ptr-ref) ENTRYPOINT(ptr-ref)
                  LENGTH(data-area)
END-EXEC

The INQUIRE PROGRAM command returns information about a particular program, map set, or partition set installed in your CICS system. All of these resources are load modules and, therefore, CICS uses the same INQUIRE command for all three. To avoid confusion, we use the word module to refer to the object of your inquiry, except in some cases where the option applies only to executable programs.

CICS determines the information you request from both the resource definition and, where applicable, the load module. Information from the module takes precedence over that in the definition if there is a conflict. However, CICS inspects a module only if it is already loaded and is the copy currently available for use. CICS does not do a load for an INQUIRE PROGRAM command, nor attempt to autoinstall a resource for which it has no definition.

The DUMP TRANSACTION command dumps all, a series, or any single main storage area related to a task, any or all of the CICS resource definitions (DCT, FCT, SIT, or TCT), or all of these together.

If there is no entry in the system dump table for the specified DUMPCODE, a temporary entry is made. This entry is lost on the next CICS start. The system dump table is described in the CICS Problem Determination Guide. The syntax for this command is:

EXEC CICS DUMP TRANSACTION DUMPCODE(name)
          RESP(data-area)
END-EXEC

The option in this command is:

DUMPCODE(name)

Specifies a name (1–4 characters) that identifies the dump. If the name contains any leading or imbedded blanks, the dump is produced but INVREQ is raised. No entry is added to the system dump table.

If you omit all the options except DUMPCODE, you get the same dump as if you specified TASK, but without the DL/I control blocks.

The SYNCPOINT ROLLBACK command backs out any updates to protected resources and returns them to a state they were in before this transaction began. The syntax is as follows:

EXEC CICS SYNCPOINT ROLLBACK
END-EXEC

ROLLBACK specifies that all changes to recoverable resources made by the task since its last syncpoint are to be backed out. This option can be used to tidy up protected resources in a HANDLE ABEND routine, or to revoke database changes after the application program finds irrecoverable errors in its input data.

The WRITE OPERATOR command enables an application to write a message to one or more system consoles and, if necessary, wait for a reply. The command can specify route codes. This is of particular use to application packages that need to issue their own system operator messages.

As a result of a change in the way CICS handles messages sent to the console, text lengths of greater than 113 characters are split into two lines:

EXEC CICS WRITE OPERATOR
          TEXT(data-value)
END-EXEC

The option for this command is:

In addition to the previous commands, the error handling program also uses a number of other commands including those which enable you to add a date and time stamp in a variety of formats to the messages. They are EXEC CICS ASKTIME and EXEC CICS FORMATTIME. Finally, the command EXEC CICS ISSUE DISCONNECT is used when you need to drop the session of the end user’s terminal. For the details of these commands, look in the CICS Application Programming Reference.