Progress0 of 0 lessons

CICS PURGE MESSAGE - Message Purge Control

CICS PURGE MESSAGE provides message purging capabilities for programs and transactions. It enables programs to purge messages, manage message cleanup, and handle message purging in CICS environments.

What is CICS PURGE MESSAGE?

CICS PURGE MESSAGE is a command that allows programs to purge or remove messages from message queues, terminals, or other message storage areas. It provides message cleanup capabilities, queue management, and message purging for CICS applications.

Command Syntax

cobol
1
2
3
4
5
6
EXEC CICS PURGE MESSAGE [QUEUE(queue-name)] [TERMINAL(terminal-id)] [MESSAGEID(message-id)] [RESP(response-code)] END-EXEC

Parameters

Optional Parameters

  • QUEUE(queue-name) - Name of the message queue to purge
  • TERMINAL(terminal-id) - Terminal ID to purge messages from
  • MESSAGEID(message-id) - Specific message ID to purge
  • RESP(response-code) - Response code variable

Purge Types

Queue Purge

Purging messages from queues

  • MESSAGE QUEUE PURGE - Purge all messages from queue
  • SELECTIVE PURGE - Purge specific messages
  • BULK PURGE - Purge multiple messages
  • CONDITIONAL PURGE - Purge based on conditions

Terminal Purge

Purging messages from terminals

  • TERMINAL MESSAGE PURGE - Purge terminal messages
  • USER MESSAGE PURGE - Purge user messages
  • DISPLAY PURGE - Purge display messages
  • NOTIFICATION PURGE - Purge notification messages

System Purge

Purging system messages

  • SYSTEM MESSAGE PURGE - Purge system messages
  • LOG MESSAGE PURGE - Purge log messages
  • AUDIT MESSAGE PURGE - Purge audit messages
  • ERROR MESSAGE PURGE - Purge error messages

Data Purge

Purging data messages

  • DATA MESSAGE PURGE - Purge data messages
  • FILE MESSAGE PURGE - Purge file messages
  • RECORD MESSAGE PURGE - Purge record messages
  • BATCH MESSAGE PURGE - Purge batch messages

Programming Examples

Basic Message Purge

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
IDENTIFICATION DIVISION. PROGRAM-ID. PURGE01. DATA DIVISION. WORKING-STORAGE SECTION. 01 QUEUE-NAME PIC X(8) VALUE 'MSGQUEUE'. 01 TERMINAL-ID PIC X(4) VALUE 'TERM'. 01 RESPONSE-CODE PIC S9(8) COMP. 01 PURGE-NEEDED PIC X(1) VALUE 'Y'. PROCEDURE DIVISION. IF PURGE-NEEDED = 'Y' DISPLAY 'Purging messages from queue...' EXEC CICS PURGE MESSAGE QUEUE(QUEUE-NAME) TERMINAL(TERMINAL-ID) RESP(RESPONSE-CODE) END-EXEC IF RESPONSE-CODE = DFHRESP(NORMAL) DISPLAY 'Messages purged successfully' DISPLAY 'Queue: ' QUEUE-NAME DISPLAY 'Terminal: ' TERMINAL-ID ELSE DISPLAY 'Failed to purge messages' END-IF ELSE DISPLAY 'No purge needed' END-IF EXEC CICS RETURN END-EXEC.

Advanced Message Purge

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
IDENTIFICATION DIVISION. PROGRAM-ID. PURGE02. DATA DIVISION. WORKING-STORAGE SECTION. 01 QUEUE-NAME PIC X(8) VALUE 'MSGQUEUE'. 01 TERMINAL-ID PIC X(4) VALUE 'TERM'. 01 MESSAGE-ID PIC X(8) VALUE 'MSG001'. 01 RESPONSE-CODE PIC S9(8) COMP. 01 PURGE-TYPE PIC X(1). 01 PURGE-COUNT PIC S9(4) COMP VALUE 0. PROCEDURE DIVISION. PERFORM DETERMINE-PURGE-TYPE PERFORM PURGE-MESSAGES EXEC CICS RETURN END-EXEC. DETERMINE-PURGE-TYPE. *> Add logic to determine purge type MOVE 'Q' TO PURGE-TYPE. PURGE-MESSAGES. EVALUATE PURGE-TYPE WHEN 'Q' EXEC CICS PURGE MESSAGE QUEUE(QUEUE-NAME) RESP(RESPONSE-CODE) END-EXEC ADD 1 TO PURGE-COUNT WHEN 'T' EXEC CICS PURGE MESSAGE TERMINAL(TERMINAL-ID) RESP(RESPONSE-CODE) END-EXEC ADD 1 TO PURGE-COUNT WHEN 'M' EXEC CICS PURGE MESSAGE MESSAGEID(MESSAGE-ID) RESP(RESPONSE-CODE) END-EXEC ADD 1 TO PURGE-COUNT WHEN OTHER DISPLAY 'Unknown purge type' END-EVALUATE IF RESPONSE-CODE = DFHRESP(NORMAL) DISPLAY 'Purge operation ' PURGE-COUNT ' successful' ELSE DISPLAY 'Purge operation ' PURGE-COUNT ' failed' END-IF.

Error Handling with Message Purge

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
IDENTIFICATION DIVISION. PROGRAM-ID. PURGE03. DATA DIVISION. WORKING-STORAGE SECTION. 01 QUEUE-NAME PIC X(8) VALUE 'MSGQUEUE'. 01 RESPONSE-CODE PIC S9(8) COMP. 01 RETRY-COUNT PIC S9(2) COMP VALUE 0. 01 MAX-RETRIES PIC S9(2) COMP VALUE 3. PROCEDURE DIVISION. PERFORM PURGE-WITH-ERROR-HANDLING EXEC CICS RETURN END-EXEC. PURGE-WITH-ERROR-HANDLING. PERFORM PURGE-MESSAGE IF RESPONSE-CODE NOT = DFHRESP(NORMAL) AND RETRY-COUNT < MAX-RETRIES ADD 1 TO RETRY-COUNT DISPLAY 'Retry ' RETRY-COUNT ' purging messages' PERFORM PURGE-WITH-ERROR-HANDLING END-IF. PURGE-MESSAGE. EXEC CICS PURGE MESSAGE QUEUE(QUEUE-NAME) RESP(RESPONSE-CODE) END-EXEC EVALUATE RESPONSE-CODE WHEN DFHRESP(NORMAL) DISPLAY 'Messages purged successfully' WHEN DFHRESP(INVREQ) DISPLAY 'Invalid purge request' WHEN DFHRESP(NOTFND) DISPLAY 'Queue or messages not found' WHEN DFHRESP(NOTAUTH) DISPLAY 'Not authorized to purge messages' WHEN DFHRESP(QIDERR) DISPLAY 'Queue ID error' WHEN OTHER DISPLAY 'Unexpected error occurred' END-EVALUATE.

Message Purge Management

Purge Control

  • Purge Initiation - Initiate purge operations
  • Purge Management - Manage purge processes
  • Purge Monitoring - Monitor purge status
  • Purge Completion - Complete purge operations

Queue Management

  • Queue Cleanup - Clean up message queues
  • Queue Optimization - Optimize queue performance
  • Queue Monitoring - Monitor queue status
  • Queue Maintenance - Maintain queue integrity

Resource Management

  • Resource Cleanup - Clean up message resources
  • Resource Optimization - Optimize resource usage
  • Resource Monitoring - Monitor resource consumption
  • Resource Recovery - Recover from resource issues

Error Recovery

  • Error Detection - Detect purge errors
  • Error Recovery - Recover from purge errors
  • Retry Mechanisms - Implement retry logic
  • Fallback Procedures - Use fallback procedures

Error Handling

Common Response Codes

  • DFHRESP(NORMAL) - Messages purged successfully
  • DFHRESP(INVREQ) - Invalid purge request
  • DFHRESP(NOTFND) - Queue or messages not found
  • DFHRESP(NOTAUTH) - Not authorized to purge messages
  • DFHRESP(QIDERR) - Queue ID error
  • DFHRESP(TERMIDERR) - Terminal ID error

Performance Considerations

Purge Efficiency

  • Optimize purge operations - Use efficient purge patterns
  • Minimize purge overhead - Reduce purge processing overhead
  • Use appropriate purge types - Choose appropriate purge methods
  • Monitor purge frequency - Track purge occurrence patterns

System Impact

  • Monitor system impact - Track how purges affect the system
  • Optimize purge handling - Ensure efficient purge processing
  • Manage resource usage - Monitor resource consumption
  • Track performance metrics - Monitor purge handling performance

Best Practices

Message Purge Best Practices

  • • Use purge operations judiciously
  • • Implement proper purge handling
  • • Ensure purge authorization
  • • Monitor purge operations
  • • Use appropriate purge timing
  • • Maintain purge audit trails
  • • Clean up resources properly

Explain It Like I'm 5 Years Old

Think of CICS PURGE MESSAGE like cleaning up your room:

  • Messy Room: "Your room is messy with toys everywhere" - Messages in queue
  • Clean Up: "Put all the toys away" - Purge messages
  • Throw Away: "Throw away broken toys" - Remove old messages
  • Organize: "Organize your room" - Clean up queue
  • Clean Room: "Now your room is clean" - Messages purged

Exercises

Exercise 1: Basic Message Purge

Create a program that purges messages from a specific queue.

Exercise 2: Conditional Message Purge

Write a program that purges messages based on different conditions.

Exercise 3: Error Handling

Implement comprehensive error handling for message purge failures.