COMMAREA Explained with a Practical CICS Example
Understand how COMMAREA passes data between CICS programs and pseudo-conversational transactions.
COMMAREA is a communication area used in CICS to pass data between programs or between transaction executions. It is especially common in pseudo-conversational applications where the program returns control to CICS and later resumes with saved state.
Why COMMAREA is needed
A CICS program should not stay active while waiting for user input. Instead, it sends a screen and returns. But when the user responds, the application needs to know what happened earlier. COMMAREA helps carry that state.
Examples of data stored in COMMAREA:
- customer number
- current screen mode
- validation status
- previous action
- small working values needed in the next step
Simple flow
Program A sends inquiry screen
↓
Program returns with COMMAREA
↓
User enters customer number
↓
CICS starts program again
↓
Program receives COMMAREA and continues
Example command
EXEC CICS RETURN
TRANSID('CUST')
COMMAREA(WS-COMMAREA)
LENGTH(LENGTH OF WS-COMMAREA)
END-EXEC.
When the transaction restarts, the program can check EIBCALEN to see if COMMAREA exists.
IF EIBCALEN > 0
MOVE DFHCOMMAREA TO WS-COMMAREA
END-IF.
Important cautions
COMMAREA has size limitations and should not be used for large data. For bigger state, applications may use channels and containers or temporary storage queues depending on standards.
Good practices:
- Keep COMMAREA small.
- Define a clear copybook layout.
- Validate length before moving data.
- Do not store sensitive data longer than needed.
- Version carefully when layouts change.
Conclusion
COMMAREA is a core CICS concept because it helps programs maintain state without holding resources. Understanding it makes pseudo-conversational CICS programs much easier to follow.