Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Summing of fields in array

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Summing of fields in array
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

Site Director


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

PostPosted: Wed Jun 13, 2007 3:41 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Sum Fields ballaswaroop DFSORT/ICETOOL 4 Tue May 02, 2017 11:07 am
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us