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

Reading 2 recs......

Status
Not open for further replies.

Pootytaint

Programmer
Jan 14, 2005
13
0
0
US
I have a program that I wrote that creates a work file to read from to create a print record. The program is a sales report that allows the user to specify how many years to compare. An example is 07-01-06 thru 07-31-06 If they answer 3 prior years it would show sales data (it also handles exact day instead of just 070106, 071005, 070104)
20060701
20050702
20040703

20060702
20050703
20040704

When I read the Work file I need to read 2 recs before writing the print record to calculate the percentage change in amount. Example:
20060701 10%
20050702 7%
20040703
Sales up 10% for 2006 over 2005, sales up 7% 2005 over 2004.

Any ideas on the best way to accomplish this?>

 
As you have been told in Comp.lang.cobol, you need to issue as many reads as required, and load each record into memory for further processing.

I would advise you to create a occurs capable of holding at least 10 years worth of data if you need to calculate percentages based on previous years, and not just the privous year. Otherwise you just need a temporary area to hold the previous record.

basic flow is.

load data into array
when your rules state you can write a record, write as many records as required by the loaded data, and clear the array.
repeat process until end of input data.
At end of file dont forget you may still have a set of records in memory waiting to be processed.


How this is accomplished really depends on your requirements, and it is not something I would explain here neither on CLC.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top