Please use the Code tags to preserve space, use the Preview button to review until correct before posting. Do not use tabs.
All three tables are different lengths. The values that you have are for what purpose? I may be being dense, but I don't see how anything in your second table (except OCCURS 64) relates to your first table.
Joined: 06 Jun 2008 Posts: 8280 Location: Dubuque, Iowa, USA
In COBOL, you can intiialize a table manually (which in your case would require 4096 MOVE statements per variable), or use VALUE statements as you have posted, or you can read the table values from a file and load them into the table. Your posted solution is as good as the other two.
This will probably work OK, but is there a more elegant / more efficient solution?
Elegance is in the eye of the beholder, so that part of your question is not answerable. And in this time of mainframes running tens of millions to hundreds of millions of COBOL statements per second of CPU time, why would you even think of efficiency at this point? The ONLY time you should EVER be concerned with efficiency is if the program is not completing within the amount of time it has for execution -- period.
As Bill already stated, in the code you posted, the field formats do not match. This means that you would fill your array element by element at its lowest level which I find neither elegant nor efficient. :-)
My approach would be to use loop to fill the first 64 inner elements, then move the first outer element to the remainder of the array, like so:
repeat varying i-inner from 1 by 1
until i-inner > 64
compute COUNT-0001 (1 i-inner) = i-inner - 1
repeat varying i-outer from 2 by 1
until i-outer > 64
move OUT-GROUP-MULT-2-0002 (1) to OUT-GROUP-MULT-2-0002 (i-outer)
An additional structure would not necessarily be required for this. Of course, if you need to do the initialization multiple times, it may be advisable to use an additional structure, so the first loop needs to be executed only once.