CICS COBOL Program Example
In this chapter, we will discuss about creating COBOL + CICS + DB2 (SENDTEXTP) with a transaction (MPK7). Creating sample COBOL CICS program has the below steps –
- Writing the CICS + COBOL Program
- Compile the COBOL + CICS program
- Define the transaction entry (PCT) in CICS
- Define the program entry (PPT) in CICS
- Issue new copy in CICS Region
- Run program in CICS region
1. Code COBOL + CICS program -
A CICS program is written in COBOL with CICS commands. These commands must be enclosed within:
EXEC CICS ... END-EXEC.
Scenario - Display welcome message at the middle of the screen.
----+----1----+----2----+----3----+----4----+----5----+----6----+-
IDENTIFICATION DIVISION.
PROGRAM-ID. SENDTXTP.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-DATA.
05 FILLER PIC X(900) VALUE SPACE.
05 WS-MESSAGE PIC X(40) VALUE
'Welcome to Mainframestechhelp'.
01 WS-LENGTH PIC 9(4) COMP.
PROCEDURE DIVISION.
MOVE 940 TO WS-LENGTH.
EXEC CICS SEND TEXT
FROM(WS-DATA)
LENGTH(WS-LENGTH)
ERASE
END-EXEC.
EXEC CICS
RETURN
END-EXEC.
GOBACK.
2. Compile the COBOL + CICS program -
Since the program contains CICS commands, it must be compiled with the CICS translator before the COBOL compiler processes it. Go through the topic - COBOL + CICS Program Compilation Process .
3. Define the transaction entry (PCT) in CICS -
After compilation, the transaction must be defined in CICS. Go through the topic - Define Transaction in CICS Region .
4. Define the program entry (PPT) in CICS -
After compilation, the program must be defined in CICS. Go through the topic - Define Application Program in CICS Region .
5. Issue new copy in CICS Region -
After entries are defined, issue a new copy to the module to pickup the load module and set it ready for the execution using the below command -
CEMT SET PROG(prog-name) NEWC


6. Run program in CICS region -
Once the new copy is successful, enter the transaction and hit "enter" to execute the program as shown below -

