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

Module 4: CICS COBOL Programming


DFHCOMMAREA

DFHCOMMAREA is the communication area: a block of storage that CICS passes from one program to another, or from one invocation of a program to the next. It is how CICS programs share data.

What DFHCOMMAREA is

  • It is a data area whose layout you define yourself, as a 01-level item in the Linkage Section.
  • CICS passes its address to the receiving program at entry, like a parameter.
  • Maximum size is 32,767 bytes. Keep it as small as the data you really need to pass.
  • The translator inserts the DFHCOMMAREA definition into the Linkage Section if you do not code it.

How data flows through it

  • Program A calls program B with EXEC CICS LINK PROGRAM('PROGB') COMMAREA(WS-AREA) LENGTH(50).
  • Program B sees the same 50 bytes as its DFHCOMMAREA, updates them, and returns.
  • When B returns, A sees the updated values in WS-AREA.
  • With EXEC CICS XCTL the control passes permanently and the commarea goes along with it.
  • With EXEC CICS RETURN TRANSID COMMAREA, the commarea is saved and passed to the next invocation of the transaction (pseudo-conversational programming).

The EIBCALEN = 0 rule

  • On the first call, when no commarea was passed, CICS sets EIBCALEN to zero.
  • Always test EIBCALEN before touching DFHCOMMAREA. Referencing DFHCOMMAREA when EIBCALEN is zero causes an abend.
  • If EIBCALEN is zero, initialize your working fields instead of reading the commarea.
  • Also check that EIBCALEN matches the length you expect before moving the commarea to your working area.

Example: passing a commarea with LINK

*-- Calling program:
EXEC CICS LINK
           PROGRAM('GETCUST')
           COMMAREA(WS-CUST-AREA)
           LENGTH(50)
      END-EXEC.

*-- Called program (GETCUST) Linkage Section:
LINKAGE SECTION.
01  DFHCOMMAREA.
       05  LK-CUST-ID              PIC X(6).
       05  LK-CUST-NAME            PIC X(30).
       05  FILLER                 PIC X(14).





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant