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

Occurs clause using varaible


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Sep 03, 2010 9:29 pm
Reply with quote

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
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Sep 03, 2010 10:48 pm
Reply with quote

In the above code -

Code:

COMPUTE WS-FLENGTH = (LENGTH OF VAR1 * WS-CNT) + LENGTH OF LS-CNT.

Needs to be changed to -

Code:

COMPUTE WS-FLENGTH = (LENGTH OF VAR1 (1) * WS-CNT) + LENGTH OF LS-CNT.

Bill
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts To search DB2 table based on Conditio... DB2 1
No new posts Updating a 1 byte thats in occurs mul... DFSORT/ICETOOL 6
No new posts NOT IN clause in COBOL pgm COBOL Programming 8
No new posts SUSBSCRIPT WITH SIGN IN PIC CLAUSE COBOL Programming 3
No new posts usage of CASE in WHERE clause DB2 10
Search our Forums:

Back to Top