Get main 24-bit or 31-bit storage.
GETMAIN >>-GETMAIN--SET(ptr-ref)--+-FLENGTH(data-value)--+-------+-+----> | '-BELOW-' | '-LENGTH(data-value)-------------' >--+---------------------+--+--------+--+-----------+-----------> '-INITIMG(data-value)-' '-SHARED-' '-NOSUSPEND-' >--+-------------+--------------------------------------------->< +-USERDATAKEY-+ '-CICSDATAKEY-'
Conditions: LENGERR, NOSTG
This command is threadsafe.
GETMAIN gets a main storage area of the size indicated by the FLENGTH option. The address of the area is returned in the pointer reference supplied in the SET option.
This command includes the LENGTH option for compatibility purposes only; for programs that run with current versions of CICS®, use FLENGTH.
CICS always allocates on 16-byte boundaries and rounds the requested length up to the nearest 16-byte multiple. There is no default initialization, so if you require the storage to be initialized to a specific bit configuration, you must use the INITIMG option.
No data-key option | USERDATAKEY specified | CICSDATAKEY specified |
---|---|---|
Storage key is determined by TASKDATAKEY on transaction definition | User-key storage. Storage is obtained from the UDSA or EUDSA if the SHARED option is not specified, or from the SDSA or ESDSA if the SHARED option is specified. | CICS-key storage. Storage is obtained from the CDSA or ECDSA. |
The data-key option on the GETMAIN command overrides the TASKDATAKEY option on the RDO TRANSACTION resource definition. For example, you can specify CICSDATAKEY to ensure that the requesting program obtains CICS-key storage from a CICS DSA, even if TASKDATAKEY(USER) is specified on the RDO TRANSACTION resource definition.
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.
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 maximum length that you can specify is the value of the limit for the corresponding DSA; that is, DSALIMIT or EDSALIMIT. These are the system initialization parameters that define the overall storage limit within which CICS can allocate and manage the individual DSAs in 24-bit and 31-bit storage, respectively.
If the length requested is greater than the corresponding DSALIMIT or EDSALIMIT value, the LENGERR condition occurs. If the length requested is less than the corresponding limit, but is greater than the available storage, a NOSTG condition occurs.
If the value of LENGTH is zero, a LENGERR condition occurs. If the length requested is greater than the available storage, a NOSTG condition occurs.
If a HANDLE CONDITION for NOSTG is active when the command is executed, control is passed to the user label supplied in the HANDLE CONDITION. This takes precedence over the NOSUSPEND option, but is deactivated by NOHANDLE or RESP.
A LENGERR condition that results from a zero or negative value being specified for FLENGTH or LENGTH will set ptr-ref to zero.
Be aware that if a task abends, any shared storage acquired is not automatically released.
Default action: terminate the task abnormally.
Default action: ignore the condition. An active HANDLE CONDITION NOSTG also raises this condition.
EXEC CICS GETMAIN SET(PTR)
FLENGTH(1024)
BELOW
INITIMG(BLANK)
You must define BLANK in your program as the character representing a space.
EXEC CICS GETMAIN SET(PTR)
FLENGTH(2048)
INITIMG(BLANK)
CICSDATAKEY