Array comparing problem

SKaushal

New Member
Hello there,

I'm having a problem with array field comparision.

I have a table "Wrk-Table-Item" With fields:
Customer
Pur-Date
Qty

Price of the Item changes frequently, so I have to keep track when the price changes and the multiply the Qty purchased by the customer betwwen those dates. Something like

Price-Dt = 04/01/04 Price = 0.27
Price-Dt = 04/04/04 price = 0.24
Price-Dt = 04/18/04 price = 0.26
.........................................
.........................................
.........................................
price-dt = 04/27/04 Price = 0.31
price-dt = 04/29/04 Price = 0.22

And For "Wrk-Table-Item"

Customer = "123" Qty = 5 Dt-of-Pur = 04/01/04
Customer = "123" Qty = 10 Dt-Of-Pur = 04/04/04
Customer = "123" Qty = 3 Dt-Of-Pur = 04/10/04
...................................................................
...................................................................
...................................................................


The out put should be like
date qty rate
04/01/04 - 04/03/04 5 0.27
04/04/04 - 04/17/04 13 0.24

And I have created two arrays - Price-Dt[62] Price[62].
for the above purpose But not getting any success.

I'm not getting how to solve the problem:
Any help will be highly appreciated.

thanks
 
Don't you have a table to keep track of the prices changes/product?
It seems to me dat it'll be more easy to have a table with fields like:
Productnumber, date, price
So if someone purchases a procuct then u just have to find the right record to establish the price:

find last table where product = product and date_price < date_purchased.
If you have the right index on the table then it's easy to find out the price.
Multiply that with qty and voila.
If that is what you mean.
You are trying to use 2 arrays but you have to fill them to, from where do you fill these arrays?
If you need to use the arrays for some reason then you must find the index number of the field with the correct date:
def var d_help as date no-undo.
def var i_tmp as integer no-undo.

do i_tel = 1 to extent array:
If datearray[i_tel] < date_purchased and
(d_help = ? or d_help < datearray[i_tel])
then assign i_tmp = i_tel
d_help = datearray[i_tel].
end.
price = pricearray[i_tmp].

assuming that each index field of the price array corresponds with the indefield of the date array.

Casper.
 
Back
Top