Mainframe Path Start learning free
Applied9 min readLesson 3 of 5

Exposing CICS and IMS programs as APIs

You do not rewrite a working CICS or IMS program to give it an API. A gateway on z/OS receives the HTTP request, converts the JSON into the program's input structure, calls the program, and converts the result back.

The request's journey

From a phone to COBOL and back
Mobile appHTTPS + JSON
API gatewaysecurity, limits
z/OS ConnectJSON ↔ copybook
CICS programCOBOL
DB2data

z/OS Connect

IBM z/OS Connect is the most common way to do this. You describe the API in an OpenAPI document, map each request and response field to the copybook, and z/OS Connect calls the program through CICS, IMS, MQ or DB2. The COBOL program still receives a COMMAREA or a channel and containers exactly as before.

Other routes

Calling the new API
$ curl -H "Authorization: Bearer eyJhbGciOi..." \
    https://api.examplebank.com/accounts/00412789
 
HTTP/1.1 200 OK
{ "accountId": "00412789", "name": "Asha Rao", "balance": 1520.75 }

Common mistakes

One API per program

Mirroring every existing transaction as its own API exposes internal design. Design APIs around business actions, such as 'get account summary', and map them to programs.

Ignoring CICS limits

A COMMAREA holds at most 32 KB. Large responses need channels and containers, or paging.

Long-running work behind a synchronous call

If processing takes minutes, the HTTP call times out. Use MQ or an asynchronous pattern and let the caller check back.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← From copybook to JSONCalling external APIs from COBOL →