View previous topic :: View next topic |
Author |
Message |
Anand_R Intermediate
Joined: 24 Dec 2002 Posts: 189 Topics: 60
|
Posted: Tue Feb 04, 2003 7:47 am Post subject: Dynamic Table size in the cobol,based on the input file recs |
|
|
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 |
|
|
Abhi Beginner
Joined: 03 Dec 2002 Posts: 21 Topics: 4 Location: India, Pune
|
Posted: Tue Feb 04, 2003 7:55 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
DaveyC Moderator
Joined: 02 Dec 2002 Posts: 151 Topics: 3 Location: Perth, Western Australia
|
Posted: Tue Feb 04, 2003 8:32 am Post subject: |
|
|
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 |
|
|
Anand_R Intermediate
Joined: 24 Dec 2002 Posts: 189 Topics: 60
|
Posted: Tue Feb 04, 2003 8:43 am Post subject: |
|
|
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 |
|
|
DaveyC Moderator
Joined: 02 Dec 2002 Posts: 151 Topics: 3 Location: Perth, Western Australia
|
Posted: Tue Feb 04, 2003 9:14 am Post subject: |
|
|
The maximum number in the ODO clause is fixed, it is only the number of repititions that is variable. _________________ Dave Crayford |
|
Back to top |
|
|
Abhi Beginner
Joined: 03 Dec 2002 Posts: 21 Topics: 4 Location: India, Pune
|
Posted: Wed Feb 05, 2003 3:08 am Post subject: |
|
|
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 |
|
|
DaveyC Moderator
Joined: 02 Dec 2002 Posts: 151 Topics: 3 Location: Perth, Western Australia
|
Posted: Wed Feb 05, 2003 3:54 am Post subject: |
|
|
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 |
|
|
|
|