IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Summing of fields in array


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vishabus

New User


Joined: 25 Oct 2006
Posts: 24
Location: India

PostPosted: Wed Jun 13, 2007 12:34 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jun 13, 2007 3:41 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts To find an array of words (sys-symbol... JCL & VSAM 9
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts Converting unpacked fields to pack us... SYNCSORT 4
Search our Forums:

Back to Top