MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Dynamic Table size in the cobol,based on the input file recs

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Tue Feb 04, 2003 7:47 am    Post subject: Dynamic Table size in the cobol,based on the input file recs Reply with quote

Hi,

I read the input file into table,which at present I hardcoded to 5000. But the input file can exceed.. Is there any way that I can dynamically change the table size that was defined in the working storage section..

any help is appreciated..

Thanks
Anand
Back to top
View user's profile Send private message
Abhi
Beginner


Joined: 03 Dec 2002
Posts: 21
Topics: 4
Location: India, Pune

PostPosted: Tue Feb 04, 2003 7:55 am    Post subject: Reply with quote

Anand, the most u can do with arrays is use the DEPENDING ON clause to declare a variable length table(array) in COBOL. Even for this u have to give the max size of the array during declaration.
The usual alternative is to use a temporary file. It does increase the IO involved but u need not worry about the array overflowing.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Tue Feb 04, 2003 8:00 am    Post subject: Reply with quote

Anand_r,

You can use the DEPENDING clause for a dynamic array declaration. Check this link for

Creating variable-length tables (DEPENDING ON)

Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Tue Feb 04, 2003 8:32 am    Post subject: Reply with quote

I've never actually used a temporary DB2 table. DB2 is slow and needs an administrator to set it up for you. Try to use core storage as much as you can. Avoid linear searches and sorts if possible.

If you don't want to use a fixed bounds array you can use a simple linked list, or a doubly linked list if you want to read backwards/forwards. If you want to key the data for very fast lookups then use a skip list, which has similar performance to balanced binary trees with less complexity. My advice is, only use an array when you are absolutely sure of the bounds. Programs that fail due to array bounds overflow suck...

linked lists in COBOL
skip lists theory
_________________
Dave Crayford
Back to top
View user's profile Send private message Send e-mail
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Tue Feb 04, 2003 8:43 am    Post subject: Reply with quote

Thanks to everyone for ur valuable response..

Ravi,
This program does not have any databse access.

Kolusu,

I know abt the depending on clause.. but this too we need to hardcode max size.. in b/w ..what is the advantage of using depending on clause.. Will it save any working storage space.. cud u please explain the advantage of this depending on clause..
Back to top
View user's profile Send private message
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Tue Feb 04, 2003 9:14 am    Post subject: Reply with quote

The maximum number in the ODO clause is fixed, it is only the number of repititions that is variable.
_________________
Dave Crayford
Back to top
View user's profile Send private message Send e-mail
Abhi
Beginner


Joined: 03 Dec 2002
Posts: 21
Topics: 4
Location: India, Pune

PostPosted: Wed Feb 05, 2003 3:08 am    Post subject: Reply with quote

Dave, the idea of using linked lists is cool and I have seen an example somewhere else other than the links that u have attached here. But none of them elaborate on how to actually create/add new nodes in a link list.

Are there any utilities to dynamically allocate memory in COBOL?
Back to top
View user's profile Send private message Send e-mail
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Wed Feb 05, 2003 3:54 am    Post subject: Reply with quote

check out CEEGTST for the LE utilities. CEEFRST frees the storage. It's a bit clunky but COBOL was not designed for dynamic data structures. The LE programming guide also has examples of linked lists in COBOL.

Use the LE services with the examples in the link and you should be fine. The link also has examples of Binary trees which are even cooler than a linked list... Have fun.
_________________
Dave Crayford
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group