Master the fundamental EXEC CICS commands that form the backbone of CICS application development. Learn program control, terminal control, file operations, and more to build robust CICS applications.
EXEC CICS commands are the building blocks of CICS applications. They provide the interface between your application programs and CICS services, enabling you to control programs, manage data, handle terminals, and coordinate transactions.
Link programs, transfer control, and manage program execution flow within CICS.
Read, write, and manage files, temporary storage, and transient data queues.
Send and receive data from terminals, manage screen displays, and handle user input.
Program control commands manage the execution flow of programs within CICS. They enable you to link programs, transfer control, and manage program resources effectively.
Purpose: Call another program and return to caller
Syntax: EXEC CICS LINK PROGRAM('program-name')
Data Passing: COMMAREA or CHANNEL
Return: Always returns to calling program
LINK Example:
1234567891011121314151617181920212223IDENTIFICATION DIVISION. PROGRAM-ID. MAINPROG. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-COMMAREA. 05 WS-CUSTOMER-ID PIC X(10). 05 WS-CUSTOMER-NAME PIC X(30). PROCEDURE DIVISION. * Get customer ID from terminal EXEC CICS RECEIVE INTO(WS-CUSTOMER-ID) END-EXEC * Link to customer processing program EXEC CICS LINK PROGRAM('CUSTPROC') COMMAREA(WS-COMMAREA) END-EXEC * Display result EXEC CICS SEND FROM(WS-COMMAREA) END-EXEC EXEC CICS RETURN END-EXEC.
Purpose: Transfer control to another program
Syntax: EXEC CICS XCTL PROGRAM('program-name')
Data Passing: COMMAREA or CHANNEL
Return: Never returns to calling program
XCTL Example:
1234567891011121314151617181920212223242526272829IDENTIFICATION DIVISION. PROGRAM-ID. MENUPROG. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-COMMAREA. 05 WS-FUNCTION PIC X(1). 88 INQUIRY VALUE 'I'. 88 UPDATE VALUE 'U'. 88 DELETE VALUE 'D'. PROCEDURE DIVISION. * Get function selection from user EXEC CICS RECEIVE INTO(WS-COMMAREA) END-EXEC * Transfer control based on function EVALUATE TRUE WHEN INQUIRY EXEC CICS XCTL PROGRAM('CUSTINQ') COMMAREA(WS-COMMAREA) END-EXEC WHEN UPDATE EXEC CICS XCTL PROGRAM('CUSTUPD') COMMAREA(WS-COMMAREA) END-EXEC WHEN DELETE EXEC CICS XCTL PROGRAM('CUSTDEL') COMMAREA(WS-COMMAREA) END-EXEC END-EVALUATE.
LOAD Command:
123456* Load program into memory EXEC CICS LOAD PROGRAM('PROGNAME') END-EXEC * Load with specific length EXEC CICS LOAD PROGRAM('PROGNAME') LENGTH(WS-PROG-LENGTH) END-EXEC
Loads a program into memory without executing it. Useful for pre-loading frequently used programs.
RELEASE Command:
12345* Release program from memory EXEC CICS RELEASE PROGRAM('PROGNAME') END-EXEC * Release all programs EXEC CICS RELEASE PROGRAM('*') END-EXEC
Removes a program from memory to free up storage space.
Terminal control commands manage communication between CICS programs and user terminals. They handle sending data to screens, receiving user input, and managing terminal sessions.
Purpose: Send data to terminal screen
Syntax: EXEC CICS SEND FROM(data-area)
Options: MAP, MAPSET, ERASE, ALARM
Use Cases: Display screens, messages, prompts
SEND Examples:
123456789101112131415* Send simple text message EXEC CICS SEND FROM('HELLO WORLD') END-EXEC * Send with map and mapset EXEC CICS SEND MAP('CUSTMAP') MAPSET('CUSTSET') FROM(WS-CUSTOMER-DATA) END-EXEC * Send with screen clearing EXEC CICS SEND FROM(WS-MESSAGE) ERASE END-EXEC * Send with alarm EXEC CICS SEND FROM('ERROR MESSAGE') ALARM END-EXEC
Purpose: Receive data from terminal
Syntax: EXEC CICS RECEIVE INTO(data-area)
Options: MAP, MAPSET, LENGTH
Use Cases: Get user input, form data
RECEIVE Examples:
1234567891011* Receive simple input EXEC CICS RECEIVE INTO(WS-USER-INPUT) END-EXEC * Receive with map and mapset EXEC CICS RECEIVE MAP('CUSTMAP') MAPSET('CUSTSET') INTO(WS-CUSTOMER-DATA) END-EXEC * Receive with length checking EXEC CICS RECEIVE INTO(WS-INPUT) LENGTH(WS-INPUT-LENGTH) END-EXEC
CONVERSE Command:
1234* Send and receive in one command EXEC CICS CONVERSE FROM(WS-MESSAGE) INTO(WS-RESPONSE) LENGTH(WS-RESP-LENGTH) END-EXEC
Combines SEND and RECEIVE operations for conversational programming.
SEND TEXT Command:
1234* Send text with formatting EXEC CICS SEND TEXT FROM(WS-MESSAGE) LENGTH(WS-MSG-LENGTH) ERASE END-EXEC
Sends text data with specific formatting and control options.
File control commands manage data access to VSAM files, databases, and other data sources. They provide the interface for reading, writing, updating, and deleting records.
Purpose: Read records from files
Syntax: EXEC CICS READ FILE('filename')
Options: INTO, RIDFLD, KEYLENGTH
Use Cases: Retrieve customer data, lookup records
READ Examples:
1234567891011121314151617* Read by key EXEC CICS READ FILE('CUSTFILE') INTO(WS-CUSTOMER-RECORD) RIDFLD(WS-CUSTOMER-ID) END-EXEC * Read with error handling EXEC CICS READ FILE('CUSTFILE') INTO(WS-CUSTOMER-RECORD) RIDFLD(WS-CUSTOMER-ID) RESP(WS-RESPONSE) END-EXEC * Check response IF WS-RESPONSE = DFHRESP(NORMAL) PERFORM PROCESS-CUSTOMER ELSE PERFORM HANDLE-ERROR END-IF
Purpose: Write new records to files
Syntax: EXEC CICS WRITE FILE('filename')
Options: FROM, RIDFLD, KEYLENGTH
Use Cases: Add new customers, create records
WRITE Examples:
123456789101112131415* Write new record EXEC CICS WRITE FILE('CUSTFILE') FROM(WS-CUSTOMER-RECORD) RIDFLD(WS-CUSTOMER-ID) END-EXEC * Write with error handling EXEC CICS WRITE FILE('CUSTFILE') FROM(WS-CUSTOMER-RECORD) RIDFLD(WS-CUSTOMER-ID) RESP(WS-RESPONSE) END-EXEC * Check for duplicate key IF WS-RESPONSE = DFHRESP(DUPREC) PERFORM HANDLE-DUPLICATE END-IF
REWRITE Command:
123* Update existing record EXEC CICS REWRITE FILE('CUSTFILE') FROM(WS-CUSTOMER-RECORD) END-EXEC
Updates an existing record that was previously read.
DELETE Command:
123* Delete record EXEC CICS DELETE FILE('CUSTFILE') RIDFLD(WS-CUSTOMER-ID) END-EXEC
Removes a record from the file.
Browse Operations:
1234567891011* Start browse EXEC CICS STARTBR FILE('CUSTFILE') RIDFLD(WS-START-KEY) END-EXEC * Read next record EXEC CICS READNEXT FILE('CUSTFILE') INTO(WS-CUSTOMER-RECORD) RIDFLD(WS-CURRENT-KEY) END-EXEC * End browse EXEC CICS ENDBR FILE('CUSTFILE') END-EXEC
Browse operations allow sequential access to file records.
Temporary Storage (TS) and Transient Data (TD) commands manage data queues for temporary storage and inter-program communication within and across CICS regions.
Purpose: Temporary data storage within region
Scope: Region-specific storage
Persistence: Survives transaction boundaries
Use Cases: Work-in-progress, temporary results
TS Commands:
12345678910* Write to TS queue EXEC CICS WRITEQ TS QUEUE('WORKDATA') FROM(WS-WORK-AREA) END-EXEC * Read from TS queue EXEC CICS READQ TS QUEUE('WORKDATA') INTO(WS-WORK-AREA) END-EXEC * Delete TS 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 Commands:
123456789* Write to TD queue EXEC CICS WRITEQ TD QUEUE('MSGQUEUE') FROM(WS-MESSAGE) LENGTH(WS-MSG-LENGTH) END-EXEC * Read from TD queue EXEC CICS READQ TD QUEUE('MSGQUEUE') INTO(WS-MESSAGE) LENGTH(WS-MSG-LENGTH) END-EXEC
Task control commands manage the execution of CICS tasks, including timing, synchronization, and task coordination. They provide control over task lifecycle and behavior.
Purpose: Pause task execution
Syntax: EXEC CICS DELAY INTERVAL(time)
Options: INTERVAL, TIME
Use Cases: Rate limiting, polling delays
DELAY Examples:
123456789* Delay for 5 seconds EXEC CICS DELAY INTERVAL(5) END-EXEC * Delay until specific time EXEC CICS DELAY TIME('14:30:00') END-EXEC * Delay with error handling EXEC CICS DELAY INTERVAL(10) RESP(WS-RESPONSE) END-EXEC
Purpose: Commit or rollback changes
Syntax: EXEC CICS SYNCPOINT
Options: ROLLBACK, COMMIT
Use Cases: Transaction consistency, error recovery
SYNCPOINT Examples:
123456789101112131415* Commit changes EXEC CICS SYNCPOINT END-EXEC * Rollback changes EXEC CICS SYNCPOINT ROLLBACK END-EXEC * Commit with error handling EXEC CICS SYNCPOINT RESP(WS-RESPONSE) END-EXEC * Check response IF WS-RESPONSE = DFHRESP(NORMAL) PERFORM SUCCESS-PROCESSING ELSE PERFORM ERROR-HANDLING END-IF
POST Command:
1234* Post event to another task EXEC CICS POST INTERVAL(0) PROGRAM('NOTIFY') COMMAREA(WS-NOTIFICATION) END-EXEC
Posts an event to another task for asynchronous communication.
WAIT Command:
12* Wait for event EXEC CICS WAIT EVENT(WS-EVENT-NAME) END-EXEC
Pauses task execution until a specific event occurs.
Question 1:
What is the difference between LINK and XCTL commands?
Question 2:
When would you use the SYNCPOINT command?
Question 3:
What are the main differences between TS and TD queues?