Progress0 of 0 lessons

CICS Operator Communication

CICS operator communication enables application programs to send messages to system operators and receive responses. This capability is essential for alerting operators to critical conditions, requesting manual intervention, and enabling two-way communication between applications and operations staff.

Operator communication in CICS uses specialized commands that allow programs to interact with the operator console, send notifications, and receive operator input. This is particularly important for error handling, system monitoring, and situations requiring human decision-making.

Overview of Operator Communication

Operator communication in CICS provides a bridge between application programs and system operators who monitor and manage the CICS region. This communication is bidirectional:

  • Application to Operator: Programs send messages using WRITE OPERATOR
  • Operator to Application: Programs receive input using READ OPERATOR
  • Message Routing: Messages can be targeted to specific operators or operator classes
  • Response Handling: Operators can respond to messages, providing input to programs

Explain It Like I'm 5 Years Old

Imagine you're playing a game and you need help from a grown-up. In CICS, your program is like you playing the game, and the operator is like the grown-up who can help.

When your program needs help or wants to tell the operator something important, it uses WRITE OPERATOR - like writing a note and giving it to the grown-up. The note might say "I need help!" or "Something went wrong!" or "Everything is working fine!"

Sometimes, your program might need to wait for the grown-up to answer a question. That's when it uses READ OPERATOR - like waiting for the grown-up to write back on your note. The program waits patiently until the operator responds, then it can continue with what it was doing.

WRITE OPERATOR Command

The WRITE OPERATOR command sends a message to one or more system operators. This is the primary mechanism for applications to communicate with operators.

Basic Syntax

cobol
1
2
3
4
5
6
7
8
9
EXEC CICS WRITE OPERATOR TEXT(message-text) [TEXTLENGTH(length)] [ROUTE(operator-id | operator-class | ALL)] [OPCLASS(operator-class)] [DEST(destination)] [RESP(response-code)] [RESP2(response2-code)] END-EXEC.

Command Options

WRITE OPERATOR Command Options
OptionDescriptionRequired
TEXTThe message text to send to operators. Can be a literal or data area containing the message.Yes
TEXTLENGTHLength of the message text. Required if TEXT is a data area, optional for literals.Conditional
ROUTESpecifies routing destination: operator ID, operator class, or ALL for all operators.No
OPCLASSSpecifies an operator class to receive the message. All operators in the class receive it.No
DESTSpecifies a destination identifier for message routing.No
RESPResponse code field to check command execution status.No
RESP2Additional response code providing detailed error information.No

Basic Example

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
IDENTIFICATION DIVISION. PROGRAM-ID. OPMSG01. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-MESSAGE PIC X(80). 01 WS-RESP PIC S9(8) COMP. 01 WS-RESP2 PIC S9(8) COMP. PROCEDURE DIVISION. MAIN-PARA. *> Send a simple informational message MOVE 'Customer file backup completed successfully' TO WS-MESSAGE. EXEC CICS WRITE OPERATOR TEXT(WS-MESSAGE) TEXTLENGTH(LENGTH OF WS-MESSAGE) RESP(WS-RESP) RESP2(WS-RESP2) END-EXEC. *> Check if command executed successfully IF WS-RESP NOT = DFHRESP(NORMAL) THEN *> Handle error condition DISPLAY 'WRITE OPERATOR failed: ' WS-RESP END-IF. EXEC CICS RETURN END-EXEC.

Routing Messages to Specific Operators

You can route messages to specific operators or operator classes using the ROUTE or OPCLASS options:

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
*> Send message to a specific operator EXEC CICS WRITE OPERATOR TEXT('Critical error detected in transaction ABC') ROUTE('OP001') RESP(WS-RESP) END-EXEC. *> Send message to all operators in a class EXEC CICS WRITE OPERATOR TEXT('Database connection pool exhausted') OPCLASS('DATABASE') RESP(WS-RESP) END-EXEC. *> Send message to all operators EXEC CICS WRITE OPERATOR TEXT('System maintenance window starting in 5 minutes') ROUTE(ALL) RESP(WS-RESP) END-EXEC.

READ OPERATOR Command

The READ OPERATOR command allows a program to read messages or commands from operators. This enables two-way communication and allows operators to provide input to running transactions.

Basic Syntax

cobol
1
2
3
4
5
6
7
8
EXEC CICS READ OPERATOR INTO(data-area) [LENGTH(data-area)] [MAXLENGTH(length-value)] [WAIT(timeout-value)] [RESP(response-code)] [RESP2(response2-code)] END-EXEC.

Command Options

READ OPERATOR Command Options
OptionDescriptionRequired
INTOData area where the operator message will be placed.Yes
LENGTHData area that receives the actual length of the message read.No
MAXLENGTHMaximum length of message to read. Prevents buffer overflow.No
WAITTimeout value in seconds. Program waits for operator input up to this time. If omitted, waits indefinitely.No
RESPResponse code field to check command execution status.No
RESP2Additional response code providing detailed error information.No

Example: Requesting Operator Approval

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
IDENTIFICATION DIVISION. PROGRAM-ID. OPAPPROV. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-OPERATOR-INPUT PIC X(80). 01 WS-INPUT-LENGTH PIC S9(4) COMP. 01 WS-RESP PIC S9(8) COMP. 01 WS-RESP2 PIC S9(8) COMP. 01 WS-APPROVAL PIC X(1). PROCEDURE DIVISION. MAIN-PARA. *> Send message requesting approval EXEC CICS WRITE OPERATOR TEXT('Large transaction detected. Approve? (Y/N)') ROUTE(ALL) RESP(WS-RESP) END-EXEC. *> Wait for operator response (30 second timeout) EXEC CICS READ OPERATOR INTO(WS-OPERATOR-INPUT) LENGTH(WS-INPUT-LENGTH) MAXLENGTH(80) WAIT(30) RESP(WS-RESP) RESP2(WS-RESP2) END-EXEC. *> Check if we got a response IF WS-RESP = DFHRESP(NORMAL) THEN *> Process operator response MOVE WS-OPERATOR-INPUT(1:1) TO WS-APPROVAL IF WS-APPROVAL = 'Y' OR WS-APPROVAL = 'y' THEN *> Proceed with transaction DISPLAY 'Transaction approved by operator' ELSE *> Cancel transaction DISPLAY 'Transaction cancelled by operator' EXEC CICS RETURN END-EXEC END-IF ELSE *> Timeout or error - take default action IF WS-RESP = DFHRESP(ENDDATA) THEN DISPLAY 'No operator response - using default' ELSE DISPLAY 'READ OPERATOR error: ' WS-RESP END-IF END-IF. EXEC CICS RETURN END-EXEC.

Operator Classes

Operator classes are groups of operators that share similar responsibilities or authorization levels. Using operator classes allows you to route messages to operators with specific roles without knowing individual operator IDs.

Common Operator Classes

Common Operator Classes
ClassDescriptionTypical Use
SYSTEMSystem operators with full system accessCritical system messages, shutdown requests
SECURITYSecurity administratorsSecurity violations, authentication failures
DATABASEDatabase administratorsDatabase errors, connection issues
APPLICATIONApplication support staffApplication errors, transaction issues

Using Operator Classes

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
*> Send security alert to security operators EXEC CICS WRITE OPERATOR TEXT('Multiple failed login attempts detected') OPCLASS('SECURITY') RESP(WS-RESP) END-EXEC. *> Send database error to database administrators EXEC CICS WRITE OPERATOR TEXT('DB2 connection pool exhausted - immediate action required') OPCLASS('DATABASE') RESP(WS-RESP) END-EXEC. *> Send system message to system operators EXEC CICS WRITE OPERATOR TEXT('System resource usage exceeds threshold') OPCLASS('SYSTEM') RESP(WS-RESP) END-EXEC.

Message Types and Severity

Operator messages can be categorized by type and severity. Understanding these categories helps you send appropriate messages and ensures operators respond appropriately.

Operator Message Types
Message TypeDescriptionExampleSeverity
InformationalMessages that provide status information or confirmationsTransaction completed successfullyLow
WarningMessages that alert operators to potential issuesDisk space usage exceeds 80%Medium
ErrorMessages that indicate errors requiring attentionFile access failed - file not foundHigh
CriticalMessages that require immediate operator interventionSystem resource exhausted - immediate action requiredCritical

Best Practices

1. Use Appropriate Message Severity

Match message severity to the actual situation. Overusing critical messages can lead to operator fatigue and reduce effectiveness.

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
*> Good: Appropriate severity *> Critical system resource issue EXEC CICS WRITE OPERATOR TEXT('CRITICAL: System storage exhausted - immediate action required') OPCLASS('SYSTEM') RESP(WS-RESP) END-EXEC. *> Bad: Overstating severity *> Routine operation completion EXEC CICS WRITE OPERATOR TEXT('CRITICAL: Daily report generation completed') ROUTE(ALL) RESP(WS-RESP) END-EXEC.

2. Provide Clear and Actionable Messages

Messages should be clear, concise, and provide enough information for operators to take action:

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
*> Good: Clear and actionable MOVE 'File CUSTFILE access failed - File not found. ' & 'Check file definition and ensure file is enabled. ' & 'Transaction ID: CUST, Program: CUSTINQ' TO WS-MESSAGE. EXEC CICS WRITE OPERATOR TEXT(WS-MESSAGE) OPCLASS('APPLICATION') RESP(WS-RESP) END-EXEC. *> Bad: Vague and unhelpful EXEC CICS WRITE OPERATOR TEXT('Error occurred') ROUTE(ALL) RESP(WS-RESP) END-EXEC.

3. Avoid High-Volume Message Generation

Don't send operator messages for routine operations or in tight loops. Use logging or journaling for routine information:

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
*> Bad: Sending message in a loop PERFORM VARYING WS-INDEX FROM 1 BY 1 UNTIL WS-INDEX > 1000 EXEC CICS WRITE OPERATOR TEXT('Processing record number') RESP(WS-RESP) END-EXEC END-PERFORM. *> Good: Use logging for routine operations PERFORM VARYING WS-INDEX FROM 1 BY 1 UNTIL WS-INDEX > 1000 *> Process record *> Log to journal instead of operator console EXEC CICS WRITE JOURNAL JFILE('APPLOG') FROM(WS-LOG-RECORD) RESP(WS-RESP) END-EXEC END-PERFORM. *> Only send operator message for summary EXEC CICS WRITE OPERATOR TEXT('Batch processing completed - 1000 records processed') OPCLASS('APPLICATION') RESP(WS-RESP) END-EXEC.

4. Handle Timeouts Appropriately

When using READ OPERATOR, always specify a timeout and handle timeout conditions gracefully:

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
*> Good: Timeout handling EXEC CICS READ OPERATOR INTO(WS-OPERATOR-INPUT) LENGTH(WS-INPUT-LENGTH) MAXLENGTH(80) WAIT(60) RESP(WS-RESP) END-EXEC. IF WS-RESP = DFHRESP(NORMAL) THEN *> Process operator response PERFORM PROCESS-OPERATOR-INPUT ELSE IF WS-RESP = DFHRESP(ENDDATA) THEN *> Timeout - take default action DISPLAY 'Operator timeout - using default action' PERFORM DEFAULT-ACTION ELSE *> Error condition DISPLAY 'READ OPERATOR error: ' WS-RESP PERFORM ERROR-HANDLING END-IF END-IF.

5. Secure Sensitive Information

Avoid including sensitive information like passwords, account numbers, or personal data in operator messages. Use references or codes instead:

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
*> Bad: Includes sensitive information EXEC CICS WRITE OPERATOR TEXT('User JOHN123 password reset requested. New password: ABC123') OPCLASS('SECURITY') RESP(WS-RESP) END-EXEC. *> Good: Uses reference instead EXEC CICS WRITE OPERATOR TEXT('Password reset requested for user ID: USER001. ' & 'Reference: REQ-2024-001234') OPCLASS('SECURITY') RESP(WS-RESP) END-EXEC.

Error Handling

Always check response codes when using operator communication commands. Common error conditions include:

Common Error Conditions
Exception ConditionDescriptionRecommended Action
NOTAUTHProgram not authorized to use operator communication commandsCheck resource security definitions and program authorization
LENGERRMessage length error - text too long or invalid length specifiedVerify message length and TEXTLENGTH parameter
ENDDATAREAD OPERATOR timeout - no operator response receivedHandle timeout condition and take appropriate default action
INVREQInvalid request - invalid operator ID, class, or destinationVerify operator IDs, classes, and routing parameters

Error Handling Example

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
EXEC CICS WRITE OPERATOR TEXT(WS-MESSAGE) TEXTLENGTH(WS-MESSAGE-LENGTH) OPCLASS('SYSTEM') RESP(WS-RESP) RESP2(WS-RESP2) END-EXEC. EVALUATE WS-RESP WHEN DFHRESP(NORMAL) *> Success - message sent CONTINUE WHEN DFHRESP(NOTAUTH) *> Not authorized - log and continue DISPLAY 'WRITE OPERATOR not authorized' *> Alternative: Write to journal instead EXEC CICS WRITE JOURNAL JFILE('APPLOG') FROM(WS-MESSAGE) RESP(WS-RESP) END-EXEC WHEN DFHRESP(LENGERR) *> Length error - truncate or split message DISPLAY 'Message too long - truncating' COMPUTE WS-MESSAGE-LENGTH = 80 EXEC CICS WRITE OPERATOR TEXT(WS-MESSAGE(1:80)) TEXTLENGTH(80) OPCLASS('SYSTEM') RESP(WS-RESP) END-EXEC WHEN OTHER *> Other error - log and handle DISPLAY 'WRITE OPERATOR error: ' WS-RESP DISPLAY 'RESP2: ' WS-RESP2 END-EVALUATE.

Exercises

Exercise 1: Basic Operator Message

Task: Write a CICS program that sends a message to operators when a file access fails.

Requirements:

  • Use WRITE OPERATOR to send an error message
  • Include the file name and error reason in the message
  • Route the message to the APPLICATION operator class
  • Handle error conditions appropriately

Exercise 2: Operator Approval Workflow

Task: Create a program that requests operator approval before processing a large transaction.

Requirements:

  • Send a message requesting approval with transaction details
  • Use READ OPERATOR to wait for operator response (30 second timeout)
  • Process 'Y' or 'N' response
  • Handle timeout by taking a default action

Exercise 3: Multi-Class Message Routing

Task: Write a program that sends different messages to different operator classes based on error type.

Requirements:

  • Send security-related errors to SECURITY operator class
  • Send database errors to DATABASE operator class
  • Send system errors to SYSTEM operator class
  • Include appropriate severity indicators in messages

Summary

CICS operator communication provides essential capabilities for applications to interact with system operators. Key points to remember:

  • WRITE OPERATOR: Sends messages to operators for notifications and alerts
  • READ OPERATOR: Receives input from operators for two-way communication
  • Operator Classes: Route messages to groups of operators with similar roles
  • Message Routing: Target specific operators, classes, or all operators
  • Error Handling: Always check response codes and handle errors appropriately
  • Best Practices: Use appropriate severity, provide clear messages, avoid high-volume messaging

Effective operator communication enhances system monitoring, enables operator intervention when needed, and provides a mechanism for applications to request human decision-making in critical situations.

Test Your Knowledge

1. What is the primary purpose of the WRITE OPERATOR command in CICS?

  • To write records to a VSAM file
  • To send messages to system operators
  • To write data to temporary storage
  • To communicate with remote CICS regions

2. Which option allows you to send a message to operators in a specific operator class?

  • OPID
  • OPCLASS
  • DEST
  • ROUTE

3. What happens if you use READ OPERATOR without specifying a timeout?

  • The command fails immediately
  • The program waits indefinitely for operator input
  • A default timeout of 30 seconds is used
  • The command is ignored

4. What is the maximum length of a message that can be sent using WRITE OPERATOR?

  • 80 characters
  • 132 characters
  • 255 characters
  • Depends on CICS configuration

5. Which command allows a CICS program to receive input from operators?

  • WRITE OPERATOR
  • READ OPERATOR
  • SEND OPERATOR
  • RECEIVE OPERATOR