---
title: "How to Handle Errors in CICS"
description: "Error handling methods in CICS. Explained real project ideas. Useful for your projects to use today."
url: https://srinimf.com/2015/08/08/best-ways-to-handle-unrecoverable-errors-in-cics-programs/
date: 2015-08-08
modified: 2021-10-17
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2015/08/cics-errors.jpg?fit=1200%2C900&ssl=1
categories: ["CICS Tips"]
tags: ["CICS mainframe Error handling", "CICS tips and Tricks"]
type: post
lang: en
---

# How to Handle Errors in CICS

## Handling Errors Method -1

**The first method is to write an error program of re-usable to call whenever you need.**

```
WORKING-STORAGE SECTION.
 *
 COPY ERRPARM.
C 01 ERROR-PARAMETERS.
C *
C 05 ERR-RESP PIC S9(8) COMP.
C 05 ERR-RESP2 PIC S9(8) COMP.
C 05 ERR-TRNID PIC X(4).
C 05 ERR-RSRCE PIC X(8).
 .
 .
 PROCEDURE DIVISION.
 .
 .
 IF RESPONSE-CODE NOT = DFHRESP(NORMAL)
 PERFORM 9999-TERMINATE-PROGRAM.
 .
 .
 9999-TERMINATE-PROGRAM.
 *
 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.
```

Here, ‘SYSERR’ is the re-usable error sub-routine.

**Also Read:** [CICS Tough Interview questions part 1 of 3](http://srinimf.com/2012/02/10/cics-tough-questions-part-1of-3/)

#### **What is an error io sub-routine**

- An error handling program usually displays an error message to the user and does extensive processing, including writing detailed error information to an error log, reversing any changes that were made to recoverable files, and producing a storage dump.
- It may also cause the program to abend, or it may just end with a RETURN command.
- Any program that branches to the error handling program will probably be required to pass along information on its current status, including information that’s available in the Execute Interface Block.

## **Handling Errors Method -2**

Sending an error message to user through CICS screen. This error message you can write in your main program.

```
EXEC CICS
       SEND TEXT FROM(ERROR-MESSAGE)
       ERASE
       ALARM
       FREEKB
 END-EXEC.
```

Related posts

- [What is EIB Storage Area in CICS](https://srinimf.com/2015/05/26/what-is-eib-storage-area-in-cics/)DateMay 26, 2015
- [CICS: How to write TIME logic in Four Ways](https://srinimf.com/2017/06/30/four-ways-in-cics-to-write-error-free-time-logic/)DateJune 30, 2017
- [CICS Sample Program to Write Header and Footer](https://srinimf.com/2016/04/06/cics-sample-code-for-header-and-footer/)DateApril 6, 2016

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2015%2F08%2F08%2Fbest-ways-to-handle-unrecoverable-errors-in-cics-programs%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2015%2F08%2Fcics-errors.jpg%3Ffit%3D1200%252C900%26ssl%3D1&description=How%20to%20Handle%20Errors%20in%20CICS)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2015/08/08/best-ways-to-handle-unrecoverable-errors-in-cics-programs/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2015/08/08/best-ways-to-handle-unrecoverable-errors-in-cics-programs/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2015/08/08/best-ways-to-handle-unrecoverable-errors-in-cics-programs/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2015/08/08/best-ways-to-handle-unrecoverable-errors-in-cics-programs/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Handle%20Errors%20in%20CICS&body=https%3A%2F%2Fsrinimf.com%2F2015%2F08%2F08%2Fbest-ways-to-handle-unrecoverable-errors-in-cics-programs%2F&share=email)
-

### Like this:

Like Loading…
