smusba
25th May 2009, 08:47
Dear,

I have written a script for price change for an item.
For ex: The fish cost $10 from 5/1/2009-5/5/2009
The cost varies to $9 from 5/6/2009-5/12/2009.
I want to get my previous Price history in my report . My script is.


field.dwar.f:
when.field.changes:
dwar.t = dwar.f

field.indt.f:
when.field.changes:
indt.t = indt.f



|****************************** function section ******************************

functions:
function read.main.table()
{
amntc = 0.0
amntp = 0.0
price = 0.0

select tdsfl015.*
from tdsfl015
where tdsfl015.shop between :dwar.f and :dwar.t
and tdsfl015.indt between :indt.f and :indt.t

selectdo

|amntp = find.prev()
price = find.prev.spric()
rprt_send()


endselect


}
function double find.prev.spric()
{
extern domain tcorno cou
extern domain tcpric pric
pric = 0.0
cou = 0.0
indtc = 0.0
select tdsls032.*
from tdsls032
where tdsls032.item = :tdsfl015.fish
and tdsls032.stdt < :indt.f
order by tdsls032.stdt desc
selectdo
if cou = 1 then
else
indtc = tdsls032.stdt
pric= tdsls032.pric
cou = cou + 1

endif
endselect
|message("Cost%d",amntp)
return(pric)

}

jp.aalders
25th May 2009, 10:50
So...what is your exact problem? If only 1 record exists in tdsls032 pric will remain null.
Can you be more specific about your problem?

smusba
25th May 2009, 10:55
See in our company the item price changes day by day as we are dealing with fisheries co. I want to know from
5th to 8th of march what was the price.
from 9th to 12th what was the price. and so on.
In short i want to know prev sales price history detail

sushil
25th May 2009, 11:10
So ,you need to check the price which the sales order has been made , right ?
then try tdsls045.

smusba
25th May 2009, 11:23
I am trying to get through tdsls032 because we maintain wholesale,retail etc price in this price master.

sushil
25th May 2009, 11:44
try this,

Check the Price , Sales date,* from tdsls045
and then compare it with tdsls032(effective date range)

So that if the user has changed price during Sales Order you can show differently

hope this helps

smusba
25th May 2009, 12:25
My friend I want to extract data from tdsfl015(customised table) and match with tdsls032.

mark_h
26th May 2009, 16:30
Well to get the most recent previous price I would use the code below:

function double find.prev.spric()
{
select tdsls032.*
from tdsls032
where tdsls032.item = :tdsfl015.fish
and tdsls032.stdt < :indt.f
order by tdsls032.stdt desc
as set with 1 rows
selectdo
endselect
return(tdsls032.pric)
}

So your current price is in the tdsfl015 table, and then you can jump to tdsls032 to get the previous price. Of course this only gets the most current price with the "as set with 1 rows". Plus you really do not need the return since you have the tdsls032 record and could use it on your report. Assuming I understand these tables and your request.