Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Dynamic COBOL array without a Times Clause

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
jdeeponline

New User


Joined: 08 Sep 2009
Posts: 27
Location: Charlotte

PostPosted: Fri Sep 18, 2009 9:10 pm    Post subject: Dynamic COBOL array without a Times Clause
Reply with quote

Hi,

Is it possible to define a dynamic COBOL array without giving a fixed upper value.

The "OCCURS X TIMES" will limit the array to occur for the maximum of X times and not beyond. Is there a way out of this?
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Sep 18, 2009 9:17 pm    Post subject:
Reply with quote

COBOL is a compiled language. At the time your program is compiled, the maximum size of the array must be known so the compiler can handle the array appropriately. If you go to the COBOL Language Reference manual (link at the top of the page), and read the syntax diagram for the OCCURS DEPENDING ON clause you will find that the upper limit is mandatory and must be an integer value.

There is no possibility of having a COBOL array where the upper limit of the number occurrences is not known at compile time.

Perhaps if you told us what you need to accomplish, rather than deciding in advance how you want to accomplish it, we can suggest some alternatives.
Back to top
View user's profile Send private message
jdeeponline

New User


Joined: 08 Sep 2009
Posts: 27
Location: Charlotte

PostPosted: Fri Sep 18, 2009 9:21 pm    Post subject: Reply to: Dynamic COBOL array without a Times Clause
Reply with quote

Thanks.

My requirement is to map certain table values using a cursor to this COBOL array. This is part of an online transaction.

However, there is a possibility that the table may get loaded every quarter and hence, arises a need to change the upper limit of the COBOL ARRAY evry time.

Giving a very high upper limit may hamper the memory allocated as I believe, even for DYNAMIC array the memory is allocated for the entire size irrespective of the "depending on" clause
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Sep 18, 2009 9:38 pm    Post subject:
Reply with quote

Hello,

Quote:
However, there is a possibility that the table may get loaded every quarter and hence, arises a need to change the upper limit of the COBOL ARRAY evry time.
Part of that quarterly activity might be to modify the code accordingly and promote the new version of the code. . .

Personally, i believe that loading an entire table into an array for online processing is a complete waste of resources. . .
Back to top
View user's profile Send private message
jdeeponline

New User


Joined: 08 Sep 2009
Posts: 27
Location: Charlotte

PostPosted: Fri Sep 18, 2009 9:54 pm    Post subject:
Reply with quote

Yes this is the concern. That we will have to modify the code every single time.

And loading the table to Array happens only once in a single thread of transactions and not for every transactions.

Appreciate all your responses. Thank you.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Sat Sep 19, 2009 12:24 am    Post subject: Reply to: Dynamic COBOL array without a Times Clause
Reply with quote

Because you use the term "Transaction" (and CICS is not mentioned) I'm not sure whether you're talking about CICS or Batch?

If Batch, what type of file, QSAM, VSAM, etc?

What is the highest potential number of records (a SWAG will do) and what's the LRECL?

Bill
Back to top
View user's profile Send private message
jdeeponline

New User


Joined: 08 Sep 2009
Posts: 27
Location: Charlotte

PostPosted: Sat Sep 19, 2009 12:37 am    Post subject:
Reply with quote

Its CICS transaction wherein the backend table values are fetched using a Cobol DB2 prog.

The tables we intend to load have at an average 500 records with an Avge length of 150.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Sat Sep 19, 2009 12:46 am    Post subject: Reply to: Dynamic COBOL array without a Times Clause
Reply with quote

I'm not a DB2 Application guy, so I'll ask whether there's any way to query DB2 (or, take a SWAG) ahead of time and get the number of associated records for the internal array?

If this is possible, then there's an easy solution.

Bill
Back to top
View user's profile Send private message
jdeeponline

New User


Joined: 08 Sep 2009
Posts: 27
Location: Charlotte

PostPosted: Sat Sep 19, 2009 12:59 am    Post subject:
Reply with quote

We have the number of records already. We have set the upper limit ffor the COBOL array accordingly. However, there is a probability that this may increase on a monthly or quarterly basis. This would result in change in the Array definition.

So the concern is if we could avoid this change of code evry time.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Sat Sep 19, 2009 1:40 am    Post subject: Reply to: Dynamic COBOL array without a Times Clause
Reply with quote

OK, here's what I think will work.

01) Define the following in LINKAGE -

Code:

01  LS-DYNAMIC-TABLE-REC.
    03 LS-DYNAMIC-NBR-RECS PIC S9(08) COMP.
    03 LS-DYNAMIC-REC PIC X(16777211).

02) In WS, define -

Code:

01  WS-DYNAMIC-TABLE-ELEMENTS.
    03  WS-DYNAMIC-POINTER POINTER VALUE NULL.
    03  WS-DYNAMIC-NBR-RECS PIC S9(08) COMP.
    03  WS-DYNAMIC-REC-KTR PIC S9(08) COMP VALUE ZERO.
    03  WS-DYNAMIC-FLENGTH PIC S9(08) COMP.
    03  WS-DYNAMIC-NEXT-POS PIC S9(08) COMP VALUE 1.
    03  WS-DYNAMIC-INITIMG PIC X(01) VALUE LOW-VALUE.
    03  WS-DYNAMIC-REC-LGTH PIC S9(08) COMP VALUE 150.

03) Then, logic in PROCEDURE -

Code:

COMPUTE WS-DYNAMIC-FLENGTH = (WS-DYNAMIC-NBR-RECS * WS-DYNAMIC-REC-LGTH).
ADD LENGTH OF LS-DYNAMIC-NBR-RECS TO WS-DYNAMIC-FLENGTH.

EXEC CICS GETMAIN
          SET    (WS-DYNAMIC-POINTER)
          FLENGTH(WS-DYNAMIC-FLENGTH)
          INITIMG(WS-DYNAMIC-INITIMG)
          NOHANDLE
END-EXEC.

IF  EIBRESP NOT = DFHRESP(NORMAL)
    PERFORM GETMAIN-ERROR-RTN
    GO TO END-OF-PROGRAM
END-IF.

SET ADDRESS OF LS-DYNAMIC-TABLE-REC TO WS-DYNAMIC-POINTER.
MOVE WS-DYNAMIC-NBR-RECS TO LS-DYNAMIC-NBR-RECS.

At this point, beginning at byte-01 of LS-DYNAMIC-REC, using the length value in WS-DYNAMIC-REC-LGTH, move each record from DB2 into LS-DYNAMIC-REC, via reference modification, adding WS-DYNAMIC-REC-LGTH to WS-DYNAMIC-NEXT-POS, for the "next" record and bumping WS-DYNAMIC-REC-KTR by 1, until WS-DYNAMIC-REC-KTR exceeds the value in WS-DYNAMIC-NBR-RECS.

FWIW, 16MB-1 (16777215) is the largest "01" storage-area you can define.

It is assumed that you've populated WS-DYNAMIC-NBR-RECS beforehand with the actual number of records (from DB2) you'll be loading.
Your mileage may vary.... icon_wink.gif

Bill
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Sat Sep 19, 2009 2:49 am    Post subject:
Reply with quote

Quote:
FWIW, 16MB-1 (16777215) is the largest "01" storage-area you can define.
Bill: I'm just curious -- where did you get this value? Enterprise COBOL supports up to 128M for both LINKAGE SECTION and WORKING-STORAGE SECTION. The CICS manual says GETMAIN with FLENGTH can get up to EDSALIMIT (or DSALIMIT, depending on which is requested) bytes of memory which for all of my regions is at least 40M and in one case is 120M (one of these days I'll have some time to figure out just what they are doing to CICS .... one of these days).
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Sat Sep 19, 2009 3:26 am    Post subject: Reply to: Dynamic COBOL array without a Times Clause
Reply with quote

Robert,

I believe 128M is the total amount of storage for LINKAGE and a given 01 level max is 16M-1.

But, maybe I'm wrong, cause I'm going by memory, which is prone to CRS spasms icon_wink.gif

Bill
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Sat Sep 19, 2009 3:44 am    Post subject:
Reply with quote

The COBOL Language Reference manual says in the Limits appendix ...
Quote:
01-49 data item size 134,217,727 bytes
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Sat Sep 19, 2009 3:58 am    Post subject: Reply to: Dynamic COBOL array without a Times Clause
Reply with quote

Oops, I think 16M-1 was the pre-Enterprise days.

Old habits die hard. icon_wink.gif

However, 16777211 is too big anyway (a/k/a Overkill) and the OP can reduce it as he sees fit.

111,848 records, with a record-length of 150, can be loaded into the 16777211 area.

Bill
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Sat Sep 19, 2009 10:37 pm    Post subject:
Reply with quote

Quote:
Oops, I think 16M-1 was the pre-Enterprise days.
Yes, I believe that was the COBOL II limit.
Back to top
View user's profile Send private message
jctgf
Currently Banned

Active User


Joined: 04 Nov 2006
Posts: 109

PostPosted: Sat Sep 26, 2009 7:05 pm    Post subject:
Reply with quote

Isn't a Temporary Storage Queue an option here? Even using the auxiliary option, handling records from it will be way faster than handling from DB2 (I think).
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us