SQL and DB2 JOBS
SQL and DB2 JOBS

Frequently asked question is – Do we really need to be coded GETMAIN and FREEMAIN commands in all CICS programs? Let us read complete post to get answer for this question.

The below is the syntax for GETMAIN command:

GETMAIN >>-GETMAIN–SET(ptr-ref)–+-FLENGTH(data-value)–+——-+-+—->     | ‘-BELOW-‘ |        ‘-LENGTH(data-value)————-‘    >–+———————+–+——–+–+———–+———–>    ‘-INITIMG(data-value)-‘ ‘-SHARED-‘ ‘-NOSUSPEND-‘    >–+————-+———————————————><    +-USERDATAKEY-+       ‘-CICSDATAKEY-‘

I need to tell some of the key points for GETMAIN.

  • LENGTH option is used CICS old version parameter
  • SHARED – This is important in GETMAIN. If you mention this option the storage will not be realease until you issue FREEMAIN command

Other points on Shared option:

  1. The storage that a task gets is available until it is released with a FREEMAIN or FREEMAIN64 command. For an area that is obtained without the SHARED option, only the task that acquired the storage can release it, and at task end CICS automatically releases such storage not already released.
  2. Any storage acquired with the SHARED option is accessible by all tasks, including those that are running with transaction isolation. However, a SHARED area is not released at task end and remains until explicitly freed; any task can issue the FREEMAIN or FREEMAIN64 request. This means that you can use SHARED storage in task-to-task communication.

The answer for GETMAIN and FREMAIN questions is -These storage control commands usually required to maintain Quasi-re-entrancy of CICS program. So, by default CICS supports quasi-re-entrancy. Due to this reason writing storage control commands in CICS programs is not meaningful. So no need to code CICS GETMAIN and FREEMAIN commands in CICS programs (according to latest CICS versions).

Advertisements