Module 11: CICS Error Handling and Debugging
EIBTRNID
EIBTRNID is the EIB field that holds the transaction identifier of the running task. It is a 4-character code like 'CUST' or 'ORDR' - the same id the user typed to start the transaction. Programs use it to know which transaction they are running under, to log errors, and to restart themselves.
What is EIBTRNID
- EIBTRNID is defined as PIC X(4) in the EIB. CICS sets it when the task starts.
- It holds the transaction id from the TRANSID option of RETURN, or the id the user typed at the terminal.
- Unlike EIBRESP, it does not change from command to command. It stays constant for the whole task.
- Error routines log EIBTRNID so support can tell which transaction produced the error.
Common uses of EIBTRNID
- Error logging: move EIBTRNID into the error record so every log entry names its transaction.
- Self-restart: a pseudo-conversational program issues EXEC CICS RETURN TRANSID(EIBTRNID) to restart the same transaction for the next user input.
- Shared programs: one program serving several transactions can branch on EIBTRNID to vary its behaviour per transaction.
- Passing to an error program: move EIBTRNID into a COMMAREA before XCTL to a central error handler, as in the example below.
Example: passing error context to an error program
- The example below captures EIB fields and transfers control to a central error program:WORKING-STORAGE SECTION. 01 ERROR-PARAMETERS. 05 ERR-RESP PIC S9(8) COMP. 05 ERR-RESP2 PIC S9(8) COMP. 05 ERR-TRNID PIC X(4). 05 ERR-RSRCE PIC X(8). PROCEDURE DIVISION. 9000-HANDLE-ERROR. MOVE EIBRESP TO ERR-RESP. MOVE EIBRESP2 TO ERR-RESP2. MOVE EIBTRNID TO ERR-TRNID. MOVE EIBRSRCE TO ERR-RSRCE. EXEC CICS XCTL PROGRAM('SYSERR') COMMAREA(ERROR-PARAMETERS) END-EXEC.
EIBTRNID good practices
- Capture EIBTRNID before any XCTL. After XCTL the new program has its own EIB, though the transaction id is usually the same.
- Compare it with 4-character literals in quotes, for example IF EIBTRNID = 'CUST'. Shorter literals are space-padded, so be exact.
- Use EIBTRNID rather than hard-coding the transaction id in messages. The same program may one day run under a different id.
