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

Dynamic Array in Cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sibi Yohannan

New User


Joined: 15 Apr 2009
Posts: 47
Location: Bangalore

PostPosted: Mon Aug 31, 2009 8:40 pm
Reply with quote

I have a need to declare an array of 100, but in the furture there is a chance to increase that as per the need, how flexible I can declare the array in dynamically?

Is it possible to declare an array dynaically so that it can accomodate any number of data.

I am aware of below type of Dynamic array

Code:
01 PAYROLL.
 02 PAYROLL-WEEK PIC 99.
 02 PAYROLL-HOURS PIC 999 OCCURS 1 TO 52
                             DEPENDING ON PAYROLL-WEEK.


Where the maximum size of the array is 52 and the space allocated to this array depends on the PAYROLL-WEEK variable defined. Is the advatage of defining a dynamic array is only with Saving the space allocation or is there any other advantage over that?

Please advice and correct me
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: Mon Aug 31, 2009 8:51 pm
Reply with quote

Are you building the array based upon number of records in a file that you read into your program?

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

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Mon Aug 31, 2009 9:29 pm
Reply with quote

Quote:
space allocated to this array depends on the PAYROLL-WEEK variable defined.

Not quite correct. Actually, space will be allocated for all occurences regardless of DEPENDING ON clause.
Check below URL if you need more information-

ODO Old topic

If you are looking for dynamic memory allocation then you should look at LE services CEEGTST and CEEFRST for starters.
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: Mon Aug 31, 2009 11:47 pm
Reply with quote

The following might be the more effective approach -

www.ibmmainframes.com/viewtopic.php?p=176368&highlight=#176368

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 Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top