Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
pkmurali wrote: |
Bill,
Can you please pitch it more on dynamic linkage storage using CICS GETMAIN with the below example.
Quote: |
If you allocated this in LINKAGE, via "CEEGTST", "GETMAIN" or "STORAGE OBTAIN" then you can specifically request only the amount of storage you need. Note: use XC GETMAIN for CICS. "CEEGTST" is allowed, but the CICS GETMAIN is preferred.
|
Code: |
LINKAGE SECTION.
01 LS-VAR.
05 LS-CNT PIC S9(04) COMP.
05 VAR1 OCCURS 1 TO 5 TIMES
DEPENDING ON LS-CNT.
10 EMPID PIC 9(5).
10 EMPNAME PIC X(25).
|
How to allocate linkage dynamically?
thanks,
Murali |
Let's say you need to allocate storage for the above group, but you really only need 3 occurences as opposed to 5.
Code: |
03 WS-FLENGTH PIC S9(08) COMP.
03 WS-FLENGTH-X REDEFINES WS-FLENGTH
PIC X(04).
03 WS-POINTER POINTER.
03 WS-CNT PIC S9(04) COMP VALUE 3.
*
COMPUTE WS-FLENGTH = (LENGTH OF VAR1 * WS-CNT) + LENGTH OF LS-CNT.
*
EXEC CICS GETMAIN SET(WS-POINTER) FLENGTH(WS-FLENGTH) INITIMG(WS-FLENGTH-X) END-EXEC.
*
SET ADDRESS OF LS-VAR TO WS-POINTER.
MOVE WS-CNT TO LS-CNT.
|
By allocating only three occurences you have saved 60-Bytes. Although just an example, if the OCO were 1 to 10000 and each table-entry was 100-Bytes, but you only need 2500, you can save 750,000 Bytes of storage. If this were defined to WS, you'd get the full allocation of 1,000,000 Bytes, regardless.
As long as the calculated FLENGTH is not greater than 16777215, the high-order byte of WS-FLENGTH will equal X'00' and you can use it as your INITIMG (Initialization Image), if you need the storage cleared to X'00's.
INITIMG is an optional keyword.
Bill |
|