MainframeMaster
Progress0 of 0 lessons

CICS Programming Models

Explore the diverse programming models available in CICS, from traditional languages like COBOL and Assembler to modern approaches including Java, Node.js, web services, and message queuing. Learn how to choose the right model for your application requirements.

Why Programming Models Matter

CICS supports multiple programming models to accommodate different development needs, skill sets, and application requirements. Understanding these models helps developers choose the most appropriate approach for their specific use case.

Flexibility

Choose the programming model that best fits your team's expertise and application requirements.

Integration

Seamlessly integrate traditional mainframe applications with modern web services and APIs.

Performance

Optimize performance by selecting the most efficient model for your specific workload.

Traditional Programming Languages

COBOL, PL/I, and Assembler are the foundation of CICS programming. These languages have been used for decades and continue to provide reliable, high-performance solutions for business applications.

COBOL

Strengths: Business logic, data processing, legacy integration

Use Cases: Financial applications, batch processing, data validation

Performance: Excellent for I/O intensive operations

Maintenance: Large pool of experienced developers

COBOL CICS Example:

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
IDENTIFICATION DIVISION. PROGRAM-ID. CUSTINQ. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 CUSTOMER-ID PIC X(10). 01 CUSTOMER-NAME PIC X(30). PROCEDURE DIVISION. EXEC CICS RECEIVE MAP('CUSTMAP') MAPSET('CUSTSET') INTO(CUSTOMER-ID) END-EXEC EXEC CICS SEND MAP('CUSTMAP') MAPSET('CUSTSET') FROM(CUSTOMER-NAME) END-EXEC EXEC CICS RETURN END-EXEC.

PL/I

Strengths: Mathematical operations, scientific computing, structured programming

Use Cases: Engineering applications, mathematical modeling, complex algorithms

Performance: Good for computational intensive tasks

Features: Built-in error handling, flexible data types

PL/I CICS Example:

pli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
CUSTINQ: PROCEDURE OPTIONS(MAIN); DECLARE CUSTOMER_ID CHAR(10); DECLARE CUSTOMER_NAME CHAR(30); /* Receive customer data from terminal */ EXEC CICS RECEIVE MAP('CUSTMAP') MAPSET('CUSTSET') INTO(CUSTOMER_ID); /* Process customer inquiry */ /* ... business logic here ... */ /* Send response to terminal */ EXEC CICS SEND MAP('CUSTMAP') MAPSET('CUSTSET') FROM(CUSTOMER_NAME); EXEC CICS RETURN; END CUSTINQ;

Assembler

Strengths: Maximum performance, direct hardware access, minimal overhead

Use Cases: Performance-critical applications, system programming, device drivers

Performance: Highest possible performance and efficiency

Complexity: Requires deep system knowledge

Assembler CICS Example:

assembler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
CUSTINQ CSECT USING *,R15 STM R14,R12,12(R13) LR R12,R15 USING CUSTINQ,R12 LA R1,COMMAREA EXEC CICS RECEIVE MAP('CUSTMAP') MAPSET('CUSTSET') INTO((R1)) /* Process customer inquiry */ /* ... business logic here ... */ EXEC CICS SEND MAP('CUSTMAP') MAPSET('CUSTSET') FROM(COMMAREA) EXEC CICS RETURN LTORG COMMAREA DS CL80

Traditional Language Comparison

LanguagePerformanceDevelopment SpeedMaintenanceBest For
COBOLHighMediumEasyBusiness applications
PL/IHighMediumMediumScientific computing
AssemblerHighestLowDifficultPerformance-critical code

Java Integration with CICS

Java integration in CICS provides modern development capabilities while maintaining the reliability and performance of the mainframe environment. The JCICS API enables Java applications to access CICS services and resources.

JCICS API Overview

Purpose: Java interface to CICS services

Benefits: Modern development, object-oriented design

Integration: Seamless CICS resource access

Performance: Optimized for CICS environment

JCICS API Features:

  • Terminal control (SEND/RECEIVE)
  • File operations (READ/WRITE)
  • Program linking and control
  • Transaction management
  • Data area operations

Java CICS Example

Structure: Standard Java application with JCICS calls

Error Handling: Java exception handling

Resources: CICS resource definitions required

Customer Inquiry Java Program:

java
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
import com.ibm.cics.server.*; import java.io.*; public class CustomerInquiry { public static void main(CommAreaHolder cah) { try { // Get terminal input Terminal terminal = new Terminal(); String customerId = terminal.receive(); // Process customer inquiry String customerName = processCustomer(customerId); // Send response to terminal terminal.send(customerName); } catch (CicsException e) { // Handle CICS errors System.err.println("CICS Error: " + e.getMessage()); } } private static String processCustomer(String id) { // Business logic implementation return "Customer: " + id; } }

Liberty JVM Server Configuration

The Liberty JVM server provides a lightweight, fast Java runtime environment within CICS. It's designed for cloud-native applications and microservices architecture.

Liberty Features:

  • Fast startup and shutdown
  • Dynamic configuration updates
  • Built-in security features
  • MicroProfile support
  • Cloud-native capabilities

Configuration Example:

xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
jsp-2.3 servlet-4.0 restConnector-2.0

Node.js in CICS

Node.js integration brings modern JavaScript development to CICS, enabling rapid development of web applications, APIs, and microservices. This approach leverages the Node.js ecosystem while maintaining CICS reliability.

Node.js Benefits

Development Speed: Rapid prototyping and development

Ecosystem: Rich npm package ecosystem

Performance: Event-driven, non-blocking I/O

Modern Features: ES6+, async/await, modules

Node.js Capabilities:

  • HTTP/HTTPS server creation
  • REST API development
  • Database connectivity
  • File system operations
  • Stream processing

Node.js CICS Example

Structure: Express.js application with CICS integration

API Design: RESTful endpoints for CICS operations

Error Handling: JavaScript try-catch blocks

Customer API Server:

javascript
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
const express = require('express'); const { CicsConnection } = require('@ibm/cics-node'); const app = express(); const port = 3000; // CICS connection const cics = new CicsConnection({ region: 'CICSREG', connection: 'DFHCNCT' }); app.get('/customer/:id', async (req, res) => { try { const customerId = req.params.id; // Call CICS program const result = await cics.link({ program: 'CUSTINQ', commarea: customerId }); res.json({ customer: result }); } catch (error) { res.status(500).json({ error: error.message }); } }); app.listen(port, () => { console.log(`Server running on port ${port}`); });

Web Services Integration

CICS web services enable integration with modern applications and systems. Support for SOAP/WSDL and JSON/REST allows CICS to participate in service-oriented architectures and cloud environments.

SOAP/WSDL Services

Protocol: SOAP over HTTP/HTTPS

Description: WSDL for service definition

Standards: WS-* specifications

Use Cases: Enterprise integration, legacy systems

SOAP Service Example:

xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
12345

JSON/REST Services

Protocol: HTTP with JSON payloads

Architecture: RESTful design principles

Standards: HTTP methods, status codes

Use Cases: Modern web apps, mobile APIs

REST API Example:

json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// GET /api/customers/12345 { "customerId": "12345", "customerName": "John Doe", "email": "john.doe@example.com", "status": "active" } // POST /api/customers { "customerName": "Jane Smith", "email": "jane.smith@example.com" } // HTTP Status Codes 200 OK - Success 201 Created - Resource created 400 Bad Request - Invalid input 404 Not Found - Resource not found 500 Internal Server Error - Server error

Web Service Configuration in CICS

CICS web services require proper configuration of URIMAP, WEBSERVICE, and PIPELINE resources. These resources define how external requests are routed to CICS programs.

Required Resources:

  • URIMAP - URL routing configuration
  • WEBSERVICE - Service definition
  • PIPELINE - Request processing
  • PROGRAM - CICS program to execute

Configuration Example:

plaintext
1
2
3
4
5
6
7
8
9
10
11
URIMAP: CUSTAPI URIPATH('/api/customers') WEBSERVICE(CUSTSVC) WEBSERVICE: CUSTSVC PIPELINE(CUSTPIPE) PIPELINE: CUSTPIPE PROGRAM(CUSTINQ) BINDING(HTTP) PROTOCOL(HTTP)

JMS/MQ Message Queuing

JMS (Java Message Service) and MQ (Message Queuing) integration enables asynchronous communication between CICS applications and other systems. This approach supports event-driven architectures and reliable message delivery.

JMS Integration

Purpose: Java-based messaging

Benefits: Platform independence, standard API

Features: Point-to-point, publish/subscribe

Use Cases: Asynchronous processing, event handling

JMS Producer Example:

java
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
import javax.jms.*; import com.ibm.mq.jms.MQQueueConnectionFactory; public class CustomerMessageProducer { public void sendCustomerUpdate(String customerId, String update) { try { // Create connection factory MQQueueConnectionFactory factory = new MQQueueConnectionFactory(); factory.setHostName("localhost"); factory.setPort(1414); factory.setQueueManager("QMGR"); // Create connection and session Connection connection = factory.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Create queue and producer Queue queue = session.createQueue("CUSTOMER.UPDATES"); MessageProducer producer = session.createProducer(queue); // Create and send message TextMessage message = session.createTextMessage(update); message.setStringProperty("CustomerID", customerId); producer.send(message); // Clean up session.close(); connection.close(); } catch (JMSException e) { e.printStackTrace(); } } }

MQ Integration

Purpose: IBM MQ messaging

Benefits: High reliability, security

Features: Guaranteed delivery, transaction support

Use Cases: Financial transactions, critical messaging

MQ Consumer Example:

java
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
import com.ibm.mq.jms.MQQueueConnectionFactory; import javax.jms.*; public class CustomerMessageConsumer { public void startListening() { try { // Create connection factory MQQueueConnectionFactory factory = new MQQueueConnectionFactory(); factory.setHostName("localhost"); factory.setPort(1414); factory.setQueueManager("QMGR"); // Create connection and session Connection connection = factory.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Create queue and consumer Queue queue = session.createQueue("CUSTOMER.UPDATES"); MessageConsumer consumer = session.createMessageListener(new MessageListener() { public void onMessage(Message message) { try { if (message instanceof TextMessage) { String text = ((TextMessage) message).getText(); String customerId = message.getStringProperty("CustomerID"); processCustomerUpdate(customerId, text); } } catch (JMSException e) { e.printStackTrace(); } } }); connection.start(); } catch (JMSException e) { e.printStackTrace(); } } private void processCustomerUpdate(String customerId, String update) { // Process customer update System.out.println("Processing update for customer: " + customerId); } }

Quick Quiz

Question 1:

What are the main advantages of using Java in CICS?

Question 2:

What is the difference between SOAP and REST web services?

Question 3:

When would you choose Assembler over COBOL for CICS programming?