MainframeMaster
Progress0 of 0 lessons

CICS Programming Models

An overview of how to build CICS applications: language options, interaction patterns, and program control.

Language Options

CICS supports multiple programming languages, each with specific strengths and use cases. Understanding these options helps you choose the right approach for your application needs.

Traditional Languages (COBOL/PL/I/Assembler)

Key Features:

  • • Native EXEC CICS commands for all CICS services
  • • Direct access to mainframe resources and performance
  • • COMMAREA for simple data passing between programs
  • • Channels & Containers for complex data structures
  • • Reentrancy and threadsafe design for scalability

Best For:

  • • High-performance transaction processing
  • • Legacy system integration and modernization
  • • Direct file and database access
  • • Complex business logic with mainframe data

Java (JCICS)

Key Features:

  • • JCICS API for CICS services within Liberty JVM server
  • • Integration with modern Java frameworks and libraries
  • • HTTP/REST, JMS/MQ, and database connectivity
  • • Object-oriented design and modern development practices
  • • Interoperability with traditional programs via Channels

Best For:

  • • Web services and API development
  • • Integration with modern enterprise systems
  • • Complex business logic with Java frameworks
  • • Teams with Java expertise

Language Comparison

FeatureCOBOL/PL/IJava (JCICS)
PerformanceNative, optimalJVM overhead
Development SpeedTraditionalModern, faster
IntegrationMainframe nativeModern APIs
MaintenanceLegacy expertiseModern practices

COBOL with EXEC CICS

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
IDENTIFICATION DIVISION. PROGRAM-ID. SAMPLE01. 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. EXEC CICS RECEIVE INTO(WS-COMMAREA) END-EXEC * Process customer data EXEC CICS LINK PROGRAM('CUSTVAL') COMMAREA(WS-COMMAREA) END-EXEC EXEC CICS RETURN END-EXEC.

Java with JCICS

java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import com.ibm.cics.server.*; import com.ibm.cics.server.invocation.*; public class SampleCICS { public static void main(CommAreaHolder cah) { try { // Get customer data from commarea String customerData = cah.getString(); // Process with Java logic Customer customer = processCustomer(customerData); // Link to COBOL program ProgramManager pm = new ProgramManager(); pm.link("CUSTVAL", customer.getData()); } catch (Exception e) { // Error handling } } }

Conversational vs Pseudo-Conversational

Understanding the difference between conversational and pseudo-conversational programming models is crucial for designing scalable CICS applications. Each approach has specific advantages and use cases.

Conversational Programming

How it works:

  • • Task remains active throughout the entire conversation
  • • Program maintains control between user interactions
  • • Variables and state persist in memory
  • • Direct control over the conversation flow

Advantages:

  • • Simple programming model
  • • Direct control over conversation
  • • Easy state management
  • • Good for simple applications

Disadvantages:

  • • Poor scalability (ties up resources)
  • • Limited concurrent users
  • • Resource intensive
  • • Not suitable for high-volume systems

Pseudo-Conversational Programming

How it works:

  • • Task ends after each screen interaction
  • • State is preserved in COMMAREA or Channels
  • • New task starts for next interaction
  • • State is restored from saved data

Advantages:

  • • Excellent scalability
  • • Supports many concurrent users
  • • Efficient resource utilization
  • • Industry best practice

Disadvantages:

  • • More complex programming
  • • Requires careful state management
  • • Need to handle state restoration
  • • More planning required

Flow Comparison

Conversational Flow:

User enters transaction
Program starts and stays active
Sends screen, waits for input
Processes input, sends next screen
Continues until conversation ends

Pseudo-Conversational Flow:

User enters transaction
Program starts, processes, sends screen
Saves state in COMMAREA, ends task
User responds, new task starts
Restores state, continues processing

Conversational COBOL 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. CONVERSATIONAL. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-SCREEN-DATA. 05 WS-USER-INPUT PIC X(80). 05 WS-RESPONSE PIC X(80). PROCEDURE DIVISION. MAIN-LOGIC. PERFORM GET-USER-INPUT PERFORM PROCESS-INPUT PERFORM SEND-RESPONSE PERFORM GET-USER-INPUT PERFORM PROCESS-INPUT PERFORM SEND-RESPONSE EXEC CICS RETURN END-EXEC. GET-USER-INPUT. EXEC CICS RECEIVE INTO(WS-USER-INPUT) END-EXEC. PROCESS-INPUT. * Process user input here MOVE 'Processed' TO WS-RESPONSE. SEND-RESPONSE. EXEC CICS SEND FROM(WS-RESPONSE) END-EXEC.

Pseudo-Conversational COBOL 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
IDENTIFICATION DIVISION. PROGRAM-ID. PSEUDO-CONV. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-COMMAREA. 05 WS-CONVERSATION-STATE PIC X(1). 88 FIRST-SCREEN VALUE '1'. 88 SECOND-SCREEN VALUE '2'. 05 WS-USER-DATA PIC X(80). 05 WS-PROCESSED-DATA PIC X(80). PROCEDURE DIVISION. MAIN-LOGIC. EXEC CICS RECEIVE INTO(WS-COMMAREA) END-EXEC EVALUATE TRUE WHEN FIRST-SCREEN PERFORM PROCESS-FIRST-SCREEN WHEN SECOND-SCREEN PERFORM PROCESS-SECOND-SCREEN END-EVALUATE EXEC CICS SEND FROM(WS-COMMAREA) END-EXEC EXEC CICS RETURN TRANSID('MENU') COMMAREA(WS-COMMAREA) END-EXEC.

Channels & Containers for State Management

Channels and Containers provide a modern approach to state management in CICS, offering more flexibility than COMMAREA for complex data structures.

Channels & Containers 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
IDENTIFICATION DIVISION. PROGRAM-ID. CHANNEL-EXAMPLE. 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). PROCEDURE DIVISION. MAIN-LOGIC. * Put customer data in container EXEC CICS PUT CONTAINER('CUSTDATA') CHANNEL('CUSTOMER') FROM(WS-CUSTOMER-DATA) END-EXEC * Link to next program with channel EXEC CICS LINK PROGRAM('CUSTPROC') CHANNEL('CUSTOMER') END-EXEC EXEC CICS RETURN END-EXEC.

Reading from Containers

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
IDENTIFICATION DIVISION. PROGRAM-ID. READ-CONTAINER. 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). PROCEDURE DIVISION. MAIN-LOGIC. * Get customer data from container EXEC CICS GET CONTAINER('CUSTDATA') CHANNEL('CUSTOMER') INTO(WS-CUSTOMER-DATA) END-EXEC * Process customer data PERFORM PROCESS-CUSTOMER EXEC CICS RETURN END-EXEC.

LINK, XCTL, RETURN

LINK

Call another program and return to the caller; pass COMMAREA or CHANNEL.

XCTL

Transfer control to another program without return; caller is replaced.

RETURN

Return to CICS; end the task or schedule next transid for pseudo-conv.

Quick Quiz

Question 1:

Which model is typically more scalable: conversational or pseudo-conversational?

Question 2:

What is the difference between LINK and XCTL?

Question 3:

Name a Java option for writing CICS applications.