IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Why GETMAIN Command


IBM Mainframe Forums -> CICS
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bantu2405

New User


Joined: 03 Nov 2009
Posts: 2
Location: Pune

PostPosted: Tue Nov 24, 2009 4:13 pm
Reply with quote

Hi, Could you please tell me is it necessary to use GETMAIN in all the CICS programs, as it is used to allocate memory, but there are many CICS program in my system which hardly uses GETMAIN? I want to know exactly when should one use the GETMAIN?

Thanks a lot for you help
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Nov 24, 2009 4:29 pm
Reply with quote

Everybody has his own reason to obtain storage by GETMAIN. I always
use it for getting working storage and make it addressable by DSECT's.

For instance loading a PDS directory in storage, and then processing it
to read all members.
Or to generate vsam control blocks, dcb's, system control blocks defined
only in DSECT format.

In short there are numerous reasons to use it.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Nov 24, 2009 9:22 pm
Reply with quote

Hello,

Quote:
I want to know exactly when should one use the GETMAIN?
Sounds like a solution in search of a requirement. . .

Suggest you look at other code on the system that uses GETMAIN and see why/when this is typically used in your environment.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Nov 24, 2009 10:00 pm
Reply with quote

I forgot to mention that GETMAIN is also very often used in refreshable or re-enterable or reusable programs.
Back to top
View user's profile Send private message
Debabrata Pruseth

New User


Joined: 11 Dec 2008
Posts: 59
Location: Pune , India

PostPosted: Wed Nov 25, 2009 2:20 am
Reply with quote

Hi Bantu

The most practical scenario where you come to know the importance of using GETMAIN is when you don't use it properly and the working storage variables point to wrong memory address and pick up junk values . In this case your code will abend with ASRA and the whole lot of it and you will be scratching your head from where these junk values are coming from .

So start using GETMAIN wherever it is required , it is a good practice.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Nov 25, 2009 3:20 am
Reply with quote

Since this is the CICS forum, I will stay within the scope of CICS. And as such, will not get into a lot of detail; I am not going to elaborate on the background issues/whys/wherefores - that is available on the net and in manuals.

1. A GETMAIN is a request from the ops-system for additional storage for a task. After the issuance of a FREEMAIN, the storage is nolonger assigned to the TASK. Thus, a reduction of resources for a task - very important in CICS environment.

2. Often you don't know how much extra storage you need for an internal cobol table, or simply passing data to another module within the task. If the GETMAINing module was compiled with the maximum amount of potential storage requirements within Working-Storage, then the module would be larger than necessary.
(some situations would require x amount of storage, some y)
Acquiring the necessary amount of storage at runtime (via GETMAIN) means that the load module is smaller, thus requiring less CICS resources to load. We are talking about CICS - which is online/on demand - thus reducing the likelihood of the module not being loaded (thus task not executing) or preventing another task from be initiated due to lack of available storage -
(READ: because some idiot wrote a 4 meg module that runs 1000 times a day and hogs all the resources.)

3. Because many coders are too lazy to learn anything new (GETMAIN) and due to the fact that most programmers are only concerned with their own program - and not the impact on the system as a whole (using more storage than necessary) - they don't understand that the assignment of storage via the GETMAIN command - and the freeing of it with the FREEMAIN command - don't really take that much extra time. When properly used
(READ: have a formula in the module to determine how much memory to request during runtime- sometime repeated requests are necessary)
the impact of the module on the system as a whole does not stand-out; where as a memory hog does - everytime.

hopefully Bill Boyle will chime in with his expertise.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Nov 25, 2009 3:34 am
Reply with quote

Quote:
hopefully Bill Boyle will chime in with his expertise.

or correct any of my incorrect statements.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Nov 25, 2009 4:08 am
Reply with quote

That's Bill O'Boyle

My apologies Bill.

my 8000 year old brain suffers from long term usage.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CICS

 


Similar Topics
Topic Forum Replies
No new posts RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Routing command Address SDSF to other... TSO/ISPF 2
No new posts DTL - how to define key with stacked ... TSO/ISPF 3
No new posts LTJ command CA Products 4
No new posts Query on edit primary command CLIST & REXX 5
Search our Forums:

Back to Top