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

Module 3: CICS Transactions and Commands


COMMAREA

COMMAREA (communication area) is how a pseudo-conversational program remembers things between screens. Working storage is wiped clean on every restart — the COMMAREA is not.

What is a COMMAREA

  • A COMMAREA is a data area passed from one execution of a program to the next.
  • It is the standard way to keep context (customer number, action chosen, screen state) between tasks.
  • The program declares it in the LINKAGE SECTION as DFHCOMMAREA.
  • EIBCALEN tells the program how long the incoming COMMAREA is — zero means this is the first run.
  • The maximum length is 32767 bytes, but keep it small — a few hundred bytes is typical.

How it is passed

  • RETURN ... COMMAREA(data-name): CICS saves the area and passes it to the next execution of the same transaction.
  • XCTL ... COMMAREA(data-name): passes the area to the next program in the transfer.
  • LINK ... COMMAREA(data-name): passes the area to the called program and gets changes back.
  • Typical contents: key fields, the last action, message text, and counters — never passwords or huge tables.

The standard coding pattern

  • On the first run (EIBCALEN = 0) initialize your working area; otherwise move DFHCOMMAREA into it.
  • Do all the screen logic, then RETURN with TRANSID and COMMAREA to continue — or plain RETURN to finish.
  • Example of the full pattern:-
    WORKING-STORAGE SECTION. 01 CA-AREA PIC X(124). LINKAGE SECTION. 01 DFHCOMMAREA PIC X(124). PROCEDURE DIVISION. IF EIBCALEN = ZERO MOVE SPACES TO CA-AREA ELSE MOVE DFHCOMMAREA TO CA-AREA END-IF. *--- ... screen and file logic goes here ... --- EXEC CICS RETURN TRANSID('PRGA') COMMAREA(CA-AREA) END-EXEC.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant