Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading data into a 2 dimensional table 1

Status
Not open for further replies.

carolly

Programmer
Aug 2, 2001
27
AU
I have 2 input files that I need to load the information from into a 2 dimensional table. The table data will vary, therefore should I set the size of the table at a maximum size? The report that is required from this information shows client ID's and days of hire into 4 different time frames. So should I just load the information into the table that is required for the report or all the information?
 
You don't say which language you are using, as different langauages have different conventions when it comes to a matrix.
 
I am using Cobol. I have set the table to 6 x 4, so I was just wondering if it needs to be increased do I just increase the OCCURS size?
 
In terms of IBM Mainframe and AS400/Iseries cobol, the variables will be fixed, you cannot dynamically manipulate the size of a cobol array on these platforms (as for other platforms like Fujitsu etc - I do not know).

If you want to increase the matrix size then yes, just change the value of the occurs clause, but they will have to be set to the maximum size you are expecting, and then some to prevent future errors. Not sure of the max occurs size for a cobol variable but it wouldn't surprise me if it was 32 thousand blah blah blah.

I suggest for a more definitive answer you should post this question on the Cobol forums (there is a general discussion one and a fujitsu one i think). The people who read those threads are a helpful bunch.

Best of luck::)
 
Hm... why don't you create the size of your table after you have 'found out' the required size of the table? E.g. after you have read in from your input files, you should be able to know the size of the table. From there on, then declare your table with the size (so that it would be dynamic too).

Btw, I am only guessing because I have not used cobol before :) but I guess it should work the same way too as in you are able to declare your variables anywhere you like.

Hope this helps,
Leon
 
Leon, thanks for that. I need the table to hold statistical data that I can create a report from but I am thinking that I need to set the table to the size of the incoming data which is 2 input files 1 of 6 entries and the other of 15 although the report will only have a 6 by 4 table requirement.
 
Sorry Leon, but Cobol is a declaritive language in that all variables are declared at the top of the program listing and hence the size must be known at compile time, so that the memory can be allocated before the program runs. The size of the matrix will have to be specified at this time.

But obviously if you declare a large enough matrix it is up to you as to whether or not you use all the elements. So you can introduce a bit of pseudo-dynamic coding.

This is certainly true of mainframe and as400 cobol.
 
Oops... sorry about declaring variables after you have found out the size.. I have not done cobol before so I don't know how it works. Anyway, seems like the only choice is declaring the array to the biggest size like what pipk have said.

Leon
 
Hmmm, Tough one.

Does the data really need to be in a table?

I assume:
1. The input files randomly locate data
2. The amount of input is undetermined.

Random access files come to mind. I forget which one is dynamic enough to allow indexed access based on an unknown number of entries. I.e., one that does not require preallocation.

After processing the input into a random access file, use it as your table.


Sorry for the late response.



Wil Mead
wmead@optonline.net

 
Thanks Wil but I got this one working. Onto the next one now and it is a hard one
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top