---
title: "CICS: How to Use Shared Option in GETMAIN"
description: "Frequently asked question is - Do we really need to be coded GETMAIN and FREEMAIN commands in all CICS program s? Let us read complete post to get answer for this question. SQL and DB2 JOBS. The below..."
url: https://srinimf.com/2016/01/05/cics-storage-getmain-shared-option/
date: 2016-01-05
modified: 2026-10-10
author: "Srini"
categories: ["CICS Tips"]
tags: ["cics commands", "CICS tips and Tricks"]
type: post
lang: en
---

# CICS: How to Use Shared Option in GETMAIN

Frequently asked question is – Do we really need to be coded GETMAIN and FREEMAIN commands in all [CICS program](https://srinimf.com/2017/04/12/the-best-5-cics-proven-tips-that-unloacked-now/)s? Let us read complete post to get answer for this question.

[![SQL and DB2 JOBS](https://i0.wp.com/srinimf.com/wp-content/uploads/2016/01/a11.png?resize=486%2C598&ssl=1)](http://www.indeed.com/jobs?q=Mainframe&indpubnum=6634974704162507)*SQL and DB2 JOBS*

The below is the syntax for GETMAIN command:

GETMAIN >>-GETMAIN–SET(*ptr-ref*)–+-FLENGTH(*data-value*)–+——-+-+—->     | ‘-BELOW-‘ |        ‘-LENGTH(*data-value*)————-‘    >–+———————+–+——–+–+———–+———–>    ‘-I**NITIMG(*****data-valu**e*)-‘ ‘**-SHARED-**‘ ‘-NOSUSPEND-‘    >–+————-+———————————————><    +-USERDATAKEY-+       ‘-CICSDATAKEY-‘

Related[Tutorial On Micro Focus COBOL](https://srinimf.com/2014/06/23/micro-focus-cobol-details/)

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](https://www-01.ibm.com/support/knowledgecenter/SSGMGV_3.1.0/com.ibm.cics.ts31.doc/dfhp3/dfhp3r3.htm). Due to this reason writing storage control commands [in CICS programs](https://srinimf.com/2012/03/24/cics-getmain/) is not meaningful. So no need to code [CICS GETMAIN](https://srinimf.com/2016/03/16/4-most-popular-technics-for-managing-storage-with-getmain-and-freemain-in-cics/) and FREEMAIN commands in CICS programs (according to latest CICS versions).

Related[CICS Files, What’s CONSISTENT Option](https://srinimf.com/2016/02/23/cics-file-read-command-option-consistent/)

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2016%2F01%2F05%2Fcics-storage-getmain-shared-option%2F&media=https%3A%2F%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2016%2F01%2Fa11.png&description=CICS%3A%20How%20to%20Use%20Shared%20Option%20in%20GETMAIN)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/01/05/cics-storage-getmain-shared-option/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/01/05/cics-storage-getmain-shared-option/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/01/05/cics-storage-getmain-shared-option/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/01/05/cics-storage-getmain-shared-option/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20CICS%3A%20How%20to%20Use%20Shared%20Option%20in%20GETMAIN&body=https%3A%2F%2Fsrinimf.com%2F2016%2F01%2F05%2Fcics-storage-getmain-shared-option%2F&share=email)
-

### Like this:

Like Loading…
