View previous topic :: View next topic
|
Author |
Message |
vishabus
New User
Joined: 25 Oct 2006 Posts: 24 Location: India
|
|
|
|
Hi,
I have a problem. There are two files input to my program. File 1 contains Fund Id and allocation percentage, alongwith some other fields.
E.g.
F1 - 10%
F2 - 20%
F3 - 30%
F4 - 15%
F5 - 25%
The second file is a mapping file which gives information about the update in fund id. Whenever a fund id needs to be changed it will be supplied from this file. The information is like
F1 F3
F4 F3
F5 F6
The interpretation of the above is that change fund id F1 to F3, change fund id F4 to F3 and F5 to F6.
Hence the new fund versus allocation mapping becomes
F3 - 10%
F2 - 20%
F3 - 30%
F3 - 15%
F6 - 25%
Now the final result should be
F2 - 20%
F3 - 55%
F6 - 25%
i.e. all the individual funds should be summed up.
Due to some constraints we need to write a COBOL program for this. I know that I can use array to store intial fund v/s allocation values, then change the fund id to the ones mentioned in file 2. But the summing of the array after making the fund changes is causing concern. I dont know how to do this in an efficient manner.
Can any one suggest something. I hope I was able to state the problem clearly |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How many records is the max that will ever be in file1 and file2?
What should happen if the sum of the %s is >100?
From what little info we have available, i'd make an array of the file2 data, then i'd read the file1 data assigning the proper fund id and releasing those records to an internal sort. The sort would sort all of the "output records" by fund-id. In the "output procedure" from the sort, i'd summarize the %s to get to the example you posted.
My approach assumes that you have posted all of the input data. If there are considerations not posted, that may not work for you. |
|
Back to top |
|
|
|