Learn the essential mechanisms for passing data between CICS programs and transactions. Master COMMAREA, Channels & Containers, data areas, and other data transfer techniques for building robust CICS applications.
Effective data passing is fundamental to CICS application design. Understanding the different mechanisms helps developers choose the most appropriate method for their specific requirements, ensuring data integrity, performance, and maintainability.
Ensure data is transferred accurately and completely between programs and transactions.
Choose efficient data passing mechanisms that minimize overhead and maximize throughput.
Design data structures that are easy to understand, modify, and debug over time.
COMMAREA is the traditional and most widely used method for passing data between CICS programs. It provides a simple, efficient way to transfer data structures between linked programs and transactions.
Size Limit: Maximum 32,767 bytes
Data Type: Character string (PIC X)
Scope: Transaction or program link
Performance: Very fast, minimal overhead
COMMAREA Advantages:
Structure: Define data layout in working storage
Passing: Use LINK or XCTL with COMMAREA parameter
Receiving: Access data from working storage
Validation: Check data integrity and format
COBOL COMMAREA Example:
12345678910111213141516171819202122232425262728293031IDENTIFICATION DIVISION. PROGRAM-ID. CUSTMAIN. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-COMMAREA. 05 WS-CUSTOMER-ID PIC X(10). 05 WS-CUSTOMER-NAME PIC X(30). 05 WS-ACTION PIC X(1). 88 INQUIRY VALUE 'I'. 88 UPDATE VALUE 'U'. 88 DELETE VALUE 'D'. PROCEDURE DIVISION. EXEC CICS RECEIVE INTO(WS-COMMAREA) END-EXEC EVALUATE TRUE WHEN INQUIRY EXEC CICS LINK PROGRAM('CUSTINQ') COMMAREA(WS-COMMAREA) END-EXEC WHEN UPDATE EXEC CICS LINK PROGRAM('CUSTUPD') COMMAREA(WS-COMMAREA) END-EXEC WHEN DELETE EXEC CICS LINK PROGRAM('CUSTDEL') COMMAREA(WS-COMMAREA) END-EXEC END-EVALUATE EXEC CICS RETURN END-EXEC.
Design Principles:
Implementation Guidelines:
Channels and Containers provide a modern, flexible approach to data passing in CICS. This mechanism supports complex data structures, multiple data types, and better organization than traditional COMMAREA.
Channel: Logical container for related data
Container: Individual data element within a channel
Data Types: Character, binary, bit, floating-point
Size Limit: Much larger than COMMAREA
Key Benefits:
Creation: Use PUT CONTAINER to create containers
Access: Use GET CONTAINER to retrieve data
Passing: Include channel in LINK/XCTL calls
Cleanup: Containers are automatically managed
COBOL Implementation Example:
12345678910111213141516171819202122232425262728293031IDENTIFICATION DIVISION. PROGRAM-ID. CUSTCHNL. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-CUSTOMER-DATA. 05 WS-CUSTOMER-ID PIC X(10). 05 WS-CUSTOMER-NAME PIC X(30). 05 WS-CUSTOMER-ADDR PIC X(50). 01 WS-ACCOUNT-DATA. 05 WS-ACCOUNT-NUM PIC X(15). 05 WS-BALANCE PIC S9(11)V99. PROCEDURE DIVISION. * Put customer data in container EXEC CICS PUT CONTAINER('CUSTDATA') CHANNEL('CUSTOMER') FROM(WS-CUSTOMER-DATA) END-EXEC * Put account data in container EXEC CICS PUT CONTAINER('ACCTDATA') CHANNEL('CUSTOMER') FROM(WS-ACCOUNT-DATA) END-EXEC * Link to processing program with channel EXEC CICS LINK PROGRAM('CUSTPROC') CHANNEL('CUSTOMER') END-EXEC EXEC CICS RETURN END-EXEC.
Containers support various operations for creating, accessing, and managing data. Understanding these operations is essential for effective use of the Channels & Containers mechanism.
Container Creation:
12345678910* Create container with character data EXEC CICS PUT CONTAINER('CUSTNAME') CHANNEL('CUSTOMER') FROM(WS-CUSTOMER-NAME) END-EXEC * Create container with binary data EXEC CICS PUT CONTAINER('CUSTBAL') CHANNEL('CUSTOMER') FROM(WS-BALANCE) FLENGTH(LENGTH OF WS-BALANCE) END-EXEC
Container Access:
12345678910* Get container data EXEC CICS GET CONTAINER('CUSTNAME') CHANNEL('CUSTOMER') INTO(WS-CUSTOMER-NAME) END-EXEC * Check if container exists EXEC CICS GET CONTAINER('CUSTNAME') CHANNEL('CUSTOMER') INTO(WS-CUSTOMER-NAME) SET(WS-CONTAINER-PTR) END-EXEC
Data Areas provide persistent storage that can be shared across multiple transactions and programs. They are useful for storing configuration data, counters, and other information that needs to persist beyond individual transaction boundaries.
Persistence: Data survives transaction boundaries
Sharing: Accessible by multiple programs
Size Limit: Maximum 32,767 bytes
Access Control: Security and authorization
Use Cases:
Reading: Use READ command to retrieve data
Writing: Use WRITE command to update data
Locking: Use REWRITE for atomic updates
Security: Control access with RACF
Data Area Example:
123456789101112131415161718192021222324252627IDENTIFICATION DIVISION. PROGRAM-ID. DATAREA. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-DATA-AREA. 05 WS-SYSTEM-STATUS PIC X(1). 88 SYSTEM-UP VALUE 'U'. 88 SYSTEM-DOWN VALUE 'D'. 05 WS-TRANS-COUNT PIC 9(10). 05 WS-LAST-UPDATE PIC X(8). PROCEDURE DIVISION. * Read system status from data area EXEC CICS READ DATASET('SYSTEM.DATA') INTO(WS-DATA-AREA) END-EXEC * Update transaction count ADD 1 TO WS-TRANS-COUNT * Write updated data back EXEC CICS WRITE DATASET('SYSTEM.DATA') FROM(WS-DATA-AREA) END-EXEC EXEC CICS RETURN END-EXEC.
Beyond the primary mechanisms, CICS provides additional options for data transfer including temporary storage, transient data, and external data sets. Each has specific use cases and characteristics.
Purpose: Temporary data storage within region
Scope: Region-specific storage
Persistence: Survives transaction boundaries
Use Cases: Work-in-progress, temporary results
TS Operations:
12345678910* Write data to temporary storage EXEC CICS WRITEQ TS QUEUE('WORKDATA') FROM(WS-WORK-AREA) END-EXEC * Read data from temporary storage EXEC CICS READQ TS QUEUE('WORKDATA') INTO(WS-WORK-AREA) END-EXEC * Delete temporary storage queue EXEC CICS DELETEQ TS QUEUE('WORKDATA') END-EXEC
Purpose: Data transfer between regions
Scope: Cross-region communication
Persistence: Survives region restarts
Use Cases: Inter-region messaging, logging
TD Operations:
123456789* Write data to transient data queue EXEC CICS WRITEQ TD QUEUE('MSGQUEUE') FROM(WS-MESSAGE) LENGTH(LENGTH OF WS-MESSAGE) END-EXEC * Read data from transient data queue EXEC CICS READQ TD QUEUE('MSGQUEUE') INTO(WS-MESSAGE) LENGTH(LENGTH OF WS-MESSAGE) END-EXEC
External data sets provide persistent storage outside of CICS control. They are useful for large data volumes, archival purposes, and integration with other systems.
File Operations:
123456789101112* Open file for reading EXEC CICS READ FILE('CUSTOMER.FILE') INTO(WS-CUSTOMER-RECORD) RIDFLD(WS-CUSTOMER-ID) END-EXEC * Write to file EXEC CICS WRITE FILE('CUSTOMER.FILE') FROM(WS-CUSTOMER-RECORD) END-EXEC * Update existing record EXEC CICS REWRITE FILE('CUSTOMER.FILE') FROM(WS-CUSTOMER-RECORD) END-EXEC
File Considerations:
Understanding the characteristics of each data passing mechanism helps developers choose the most appropriate method for their specific requirements. Consider factors like data size, persistence needs, and performance requirements.
Mechanism | Size Limit | Persistence | Performance | Best For |
---|---|---|---|---|
COMMAREA | 32KB | Transaction | Excellent | Simple data, high performance |
Channels & Containers | Large | Transaction | Very Good | Complex data, modern apps |
Data Areas | 32KB | Persistent | Good | Shared data, configuration |
Temporary Storage | Large | Region | Good | Work-in-progress, temp data |
External Files | Unlimited | Permanent | Variable | Large volumes, archival |
Choose COMMAREA when:
Choose Channels & Containers when:
Choose Data Areas when:
Choose External Files when:
Question 1:
What is the size limit for COMMAREA and when should you use it?
Question 2:
What are the advantages of Channels & Containers over COMMAREA?
Question 3:
When would you choose Data Areas over other data passing mechanisms?