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

Module 4: CICS COBOL Programming


CICS Program Structure

Every CICS COBOL program follows the same standard structure. Once you learn this skeleton, you can read any CICS program in your shop, because they all look alike.

The four divisions in a CICS program

  • IDENTIFICATION DIVISION - the same as batch: PROGRAM-ID and author information.
  • ENVIRONMENT DIVISION - usually not needed, because CICS manages all files and devices for you.
  • DATA DIVISION, WORKING-STORAGE SECTION - maps (COPY), constants, flags, response-code fields and work areas.
  • DATA DIVISION, LINKAGE SECTION - DFHEIBLK (generated by the translator) and your DFHCOMMAREA layout.
  • PROCEDURE DIVISION - your program logic, organized in paragraphs, ending with EXEC CICS RETURN.

The pseudo-conversational pattern

  • Most CICS programs are pseudo-conversational: they end after each screen but remember their data in the commarea.
  • 0000-MAIN first tests EIBCALEN. Zero means first entry: initialize and send the first screen.
  • Non-zero means the user answered: move DFHCOMMAREA to working storage and process the input.
  • Every RETURN that waits for the user passes TRANSID and COMMAREA so the next invocation continues where this one stopped.

Standard skeleton

IDENTIFICATION DIVISION.
PROGRAM-ID. CUSTINQ.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  WS-COMMAREA.
       05  WS-FIRST-FLAG            PIC X.
       05  WS-CUST-ID               PIC X(6).
01  WS-RESP                     PIC S9(8) COMP.
LINKAGE SECTION.
01  DFHCOMMAREA                 PIC X(7).
PROCEDURE DIVISION.
0000-MAIN.
IF EIBCALEN = ZERO
            PERFORM 1000-FIRST-TIME
ELSE
            MOVE DFHCOMMAREA TO WS-COMMAREA
            PERFORM 2000-PROCESS-INPUT
END-IF.
EXEC CICS RETURN
            TRANSID(EIBTRNID)
            COMMAREA(WS-COMMAREA)
            LENGTH(7)
      END-EXEC.
1000-FIRST-TIME.
*-- Send the first screen to the user.
.
2000-PROCESS-INPUT.
*-- Handle what the user typed.
.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant