Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 4: CICS COBOL Programming


CICS-Enabled COBOL Program

A CICS-enabled COBOL program is an ordinary COBOL program that contains CICS commands and follows CICS rules. This page explains what makes a program CICS-enabled and the rules every such program must follow.

What makes a program CICS-enabled

  • The program contains at least one EXEC CICS command in its Procedure Division.
  • The source is passed through the CICS translator before the COBOL compiler sees it.
  • The translator inserts the DFHEIBLK (EIB) and DFHCOMMAREA definitions into the Linkage Section automatically.
  • The program is defined in the PPT and is started through a transaction id defined in the PCT.

Rules a CICS program must follow

  • End the program with EXEC CICS RETURN. Never use STOP RUN under CICS.
  • Do not use DISPLAY or ACCEPT for terminal I/O. Use EXEC CICS SEND and RECEIVE.
  • Do not use COBOL file verbs (READ, WRITE, REWRITE, DELETE) or OPEN/CLOSE. Use the EXEC CICS file commands.
  • Write quasi-reentrant code: the same load module can serve many tasks at once, so do not depend on values left by another task.
  • Do not use the COBOL SORT verb or other statements that need batch-only services unless your shop supports them.

Minimum parts of a CICS program

  • IDENTIFICATION DIVISION with a PROGRAM-ID, like any COBOL program.
  • DATA DIVISION with a LINKAGE SECTION that declares DFHEIBLK and DFHCOMMAREA.
  • PROCEDURE DIVISION with your logic, EXEC CICS commands, and a final EXEC CICS RETURN.
  • The example below is the smallest working pattern. The translator generates DFHEIBLK for you, so you only declare DFHCOMMAREA yourself.
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
LINKAGE SECTION.
01  DFHCOMMAREA                 PIC X(10).
PROCEDURE DIVISION.
EXEC CICS SEND TEXT
               FROM('HELLO')
               LENGTH(5)
          END-EXEC.
EXEC CICS RETURN
          END-EXEC.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant