<jeff@[EMAIL PROTECTED]
> wrote in message
news:1156179310.034387.127090@[EMAIL PROTECTED]
> billious wrote:
>> <jeff@[EMAIL PROTECTED]
> wrote in message
>> news:1156164608.427833.305850@[EMAIL PROTECTED]
>> >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 re****t 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?
>> >
>>
>> A thoroughly odd requirement.
>>
>> Is your proposed re****t format supposed to be columns of years showing
>> actual and %-differential sales and lines of days? This would show a
lot
>> of
>> meaningless data. Comparing sales on any one day with sales
52/104/156...
>> weeks earlier could be done, but wouldn't seem to give you any real
data.
>> So
>> many things can happen to influence the sales on any one day (like
>> weather)
>> that comparing doesn't seem to make sense.
>>
>> What is the format of your intermediate file? Is it indexed on date,
for
>> instance? It it organised by product?
>>
>> It wouldn't seem too much of a burden to read even 10 years of data -
>> more
>> would be difficult to fit on a re****t-page - at 365 records per year,
>> that's
>> only 3,650 records.
>>
>> I'd simply read all of the data in and place it into an array in
>> working-storage. Then simply grab it back out of the array to print it
-
>> but
>> your specification isn't really that clear.
>
> Very good ideas. I believe it pointless at well.
> Here is the work rec:
>
> fd slscompwk-file.
> 01 slscompwk-rec.
> 03 slscompwk-key.
> 05 slscompwk-store-no PIC X(03).
> $xfd date=yyyymmdd
> 05 slscompwk-trx-date PIC 9(08).
>
> 03 slscompwk-key-2.
> 05 slscompwk-store-no-2 PIC X(03).
> $xfd date=yyyymmdd
> 05 slscompwk-seq-no PIC 9(08).
>
> 03 slscompwk-day pic x(03).
> 03 slscompwk-txbl-mdse PIC s9(07)v99 comp-4.
> 03 slscompwk-non-txbl-mdse PIC s9(07)v99 comp-4.
> 03 slscompwk-disc-amt PIC s9(07)v99 comp-4.
> 03 slscompwk-tax-amt PIC s9(07)v99 comp-4.
> 03 slscompwk-freight-amt PIC s9(07)v99 comp-4.
> 03 slscompwk-total PIC s9(07)v99 comp-4.
> 03 slscompwk-non-sls-amt PIC s9(07)v99 comp-4.
> 03 slscompwk-no-of-trxs PIC 9(06).
> 03 slscompwk-inv-trx-amt PIC s9(07)v99 comp-4.
> 03 slscompwk-no-of-inv-trxs PIC 9(06).
>
> Here is the code how it works now, to just read the work file until eof
> and print
>
> format-print-re****t.
> perform re****t-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-re****t-detail
> until slscompwk-EOF.
> perform fmt-rpt-totals-line.
> perform print-rpt-totals.
> perform print-end-of-re****t.
>
> re****t-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-col-hdrs.
>
>
> build-re****t-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 ac***-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.
>
Well, you're still not saying what your re****t is to detail. Is it
by-store
for a period compared to previous years' periods, and do you want an
overall
summary?
IMHO, you'd be wise to make the re****t flexible so that you can easily
accommodate changes as the boss's mood varies.
To that end, I'd build an array of sales-figures
01 sales-totals.
03 sales-totals-current-store.
05 sales-total-current-store-daily pic S9(05)V99 COMP-3 OCCURS
3660.
03 sales-totals-all-stores.
05 sales-total-all-stores-daily pic S9(05)V99 COMP-3 OCCURS
3660.
To initialise, simply move low-values to sales-totals.
Since you know the very first date that will be re****ted, and the very
last
date and you appear to be reading the file by store, all you have to do is
* Read a record.
* At EOF or change-of-store,
** write out the re****t for the previous store number.
** ac***ulate the sales-total-current-store-daily(1 to 3660) into
sales-total-all-stores-daily(1 to 3660)
** move low-values to sales-totals-current-store to clear the current
store's totals.
* IF the record read is dated >=start-date and <=end-date for the re****t,
calculate the number-of-days-after-start-date (+1) and ac***ulate the
sales
figures into
sales-total-current-store-daily(number-of-days-after-start-date
+ 1)
The re****t is then simple:
Calculate the number-of-days-after-start-date for the first line of the
re****t. This is the index into the sales-total-current-store-daily array
that contains the sales figure to be re****ted. The "previous-year" figure
is
at the index that is 364 lower, the year before that 364 lower still and
so
on (364 because you appear to need 52 weeks exactly) Since you have the
two
sales figures, you can calculate the %change.
Then there's the re****t layout. It's a silly useless re****t, but still,
can't argue with the customer if you're being paid...
I'd suggest (eg)
2002sales 2002-3% 2003sales 2003-4% 2004sales ...2006 sales SATURDAY
2006date 2005date 2004date...
Which shows left-to-right sales figures and %change between years, and the
corresponding dates for the xxxday. This keeps the sales data and the
dates
data visible but separate.
Given an example of a re****t for 3 years, starting 20060701 and ending
20060731:
Your very-first date is 20040703. This is index 1 in your array. 20040704
is
index 2 and so on.20050702 is index 365. 20060701 is index 729 (all
calculated as #days after 20040702)
to produce your re****t, 2006 figures are at
sales-total-current-store-daily(729), 2005 at ...(365) 2004 @[EMAIL PROTECTED]
...(1)
The next line is ...(730),...(366),...(2)
and so on for the 31 days of July.
Now if the boss wants 2 or three months, or even a year - then the data's
already being stored and all you need is to change the number of days
re****ted. Different number of years, just change the number of columns
produced - the algorithm doesn't change.
And as a bonus, if you move sales-totals-all-stores to
sales-totals-current-store after completing the re****t for the last store,
you can use exactly the same routine to produce the figures for ALL
stores.


|