Code Comments
Programming Forum and web based access to our favorite programming groups.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?
Post Follow-up to this messageIn article <1156164371.856184.15880@m79g2000cwm.googlegroups.com>, <jeff@sum-it.com> wrote: >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. That's usually accomplished by coding two READ statements. DD
Post Follow-up to this messageWouldn't I need a few loops to handle the prior years and also reset a counter after your counter is = prior years? docdw...@panix.com () wrote: > In article <1156164371.856184.15880@m79g2000cwm.googlegroups.com>, > <jeff@sum-it.com> wrote: > > That's usually accomplished by coding two READ statements. > > DD
Post Follow-up to this messageIn article <1156167015.357296.277760@m79g2000cwm.googlegroups.com>, <jeff@sum-it.com> wrote: >Wouldn't I need a few loops to handle the prior years and also reset a >counter after your counter is = prior years? I'm not sure... why don't you post the code you've developed that shows this approach and maybe it will be clearer? [top post on top of top post - nothing new below] DD > > >docdw...@panix.com () wrote: >
Post Follow-up to this message<jeff@sum-it.com> wrote in message news:1156167015.357296.277760@m79g2000cwm.googlegroups.com... > Wouldn't I need a few loops to handle the prior years and also reset a > counter after your counter is = prior years? As DD said, if you want two records in memory at one time, you'll certainly need to execute at least two READs. If you don't have a fixed number of records in your file so you could code a READ for each record, a loop of some kind does sound quite promising. But that would depend on the code you are currently using, conveniently not shown. MCM
Post Follow-up to this messageThanks DD. Here is how it is accomplished now. It reads a work file I created and just prints the records, I will need to change the structure on how to accomplish this. That is where I am stuck. format-print-report. perform report-initialization. move '00000000000' to slscompwk-key slscompwk-key-2. move "N" to ws-slscompwk-EOF. perform start-slscompwk-file-nlt-2. perform rd-slscompwk-file-next. perform build-report-detail until slscompwk-EOF. perform fmt-rpt-totals-line. perform print-rpt-totals. perform print-end-of-report. report-initialization. move ws-store-no to rpt-parm-store-no. move "Date: " to rpt-parm-type-1, rpt-parm-type-2. perform print-std-rpt-hdr. perform print-legend. perform print-rpt-parameter-hdrs. perform print-rpt-col-hdrs. build-report-detail. perform format-print-detail-record. perform print-rpt-detail-line. if spacer-count = ws-number-prior-years move 0 to spacer-count move spaces to prt-detail-line perform print-rpt-detail-line. perform accum-grand-totals. perform rd-slscompwk-file-next. if slscompwk-file-stat = 10 move "Y" to ws-slscompwk-EOF end-if. format-print-detail-record. move slscompwk-trx-date to ws-date-3. perform fmt-ws-date-3. move dspl-date to prt-trx-date. move slscompwk-day to prt-day. move slscompwk-txbl-mdse to prt-txbl-mdse. move slscompwk-disc-amt to prt-disc-amt. compute prt-net-mdse = slscompwk-txbl-mdse - slscompwk-disc-amt. move slscompwk-tax-amt to prt-tax-amt. move slscompwk-freight-amt to prt-freight-amt. move slscompwk-total to prt-total. move slscompwk-non-sls-amt to prt-non-sls-amt. move slscompwk-no-of-trxs to prt-no-of-trxs. move slscompwk-inv-trx-amt to prt-inv-trx-amt. move slscompwk-no-of-inv-trxs to prt-no-of-inv-trxs. add 1 to spacer-count. 0@m79g2000cwm.googlegroups.com>,
Post Follow-up to this messageIn article <1156169022.727565.158660@i42g2000cwa.googlegroups.com>, <jeff@sum-it.com> wrote: >Thanks DD. Here is how it is accomplished now. It reads a work file I >created and just prints the records, I will need to change the >structure on how to accomplish this. That is where I am stuck. So... if you have a parameter indicating the number of years (n) then you know you have to MOVE the current record's data to a save are and READ the file again. If the 'key' data are not the same as the previous record's then you process a new record; if they are the same then you can compute the percentage change. Lather, rinse and repeat until the number of recs with the same 'key' data = the number of years, then skip identical 'keys' and start with the next one. [end top post] DD >0@m79g2000cwm.googlegroups.com>, >
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.