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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays

Status
Not open for further replies.

bj2860

Technical User
Mar 18, 2001
1
US
How do you write a COBOL program that is suppose to print total sales for 20 salespeople that are not in sequence? Number of input records could be more than 20, but output should only be 20, plus you have to have total company sales also. Any help would be appreciated as I am lost.
Thanks
 
Hi,

You sort the records in a way that all the sales people are together.

In your program you consider a group of records with the same salesman-identifier.

But, if the idea is not to sort, you can use a table to add the sales for each salesman. Because there are only 20 of them, it will fit in a working-storage table.

something like:

01 SALES-PEOPLE.
03 SALESMAN OCCURS 20.
05 SALESMAN-IDENTIFIER PIC X(10).
05 SALESMAN-SALES PIC S9(11)V99 COMP.

You initialize the table. During the processing you look up if the salesman-identifier exists in the table. If not, you add it. You also add the sales to salesman-sales for each record you process.

I hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top