COMMAREA
Summary
COMMAREA is the name of the data area in which the data or information transferred from one program to another program. The maximum length of the data can be passed through COMMAREA is 64K.
But the recommended length is 24K and it is not preferred to pass more than 24K. COMMAREA is an option of the LINK, XCTL, and RETURN commands. The LINK and XCTL commands COMMAREA option specifies the data area name in which data is passed to the program being invoked.
The RETURN command COMMAREA option specifies the data area name in which data is passed to the transaction identified in the TRANSID option. The programs involved in communication can add the COMMAREA either in working-storage section or linkage section based on its hierarchy level.
The first program which creates the COMMAREA can define it in working-storage section and the rest of the programs should have it as DFHCOMMAREA in Linkage section. The receiving data area can be the same length or shorter than the original communication area but must not be longer.
If the receiving data area is longer than the original communication area, the transaction might attempt to read or write data outside the area that has been passed which might cause CICS to abend.
To avoid this issue, we should always check the length of COMMAREA by comparing EIBCALEN and data-area-length in LENGTH option of LINK, XCTL or RETURN command.
Using COMMAREA in RETURN command -
When a called program (executing by a LINK command) issues a RETURN command, control passes back to calling program. If the task is associated with a terminal, the TRANSID option can be used to specify the transaction that is to be associated with that terminal.
If any data area required to pass to the next transaction for the above case, COMMAREA option uses with RETURN command. COMMAREA always loads to main memory during the program execution and it won’t be removed until the task is completed successfully.
RETURN command with TRANSID option can use without COMMAREA when returning from any link level, but it can be overridden on a later RETURN command. If a RETURN command fails at the top level because of an invalid COMMAREA, the TRANSID becomes null. If a program executing RETURN command, that doesn't mean the program execution is successful.
Using COMMAREA in XCTL/LINK command -
LINK/XCTL commands can call the programs with or without COMMAREA. When a communication area is passed by using a LINK command, the calling program passes a pointer to the communication area.
If any changes made to the contents of the data area(communication area) in the called program are available to the calling program after the control returns to it.
When a communication area is passed by using an XCTL command, a copy of data area is made and that was passed to the program issuing the command. This is because the calling program may not receive the control back if explicitly specified.
If any changes made to the contents of the data area(communication area) in the called program are the latest changes and passes to the next program.