mattan
14th July 2003, 06:36
I need to write a script to search and extract the old standard cost (maybe from ticpr300) of items based on transaction date from table tdinv100.
Can anyone pls advice. Thks
tjbyfield
14th July 2003, 06:52
See my sample code below: You need to find the appropriate "cost date" before actually reading ticpr300.
function domain tcdate establish.cost.price.date(domain tcdate c_date)
{
select ticpr300.*
from ticpr300
where ticpr300._index1 = {:....item, :...cntr}
and ticpr300.indt <= :c_date
order by ticpr300.item desc, ticpr300.cntr desc,
ticpr300.indt desc, ticpr300.cpcp desc
as set with 1 rows
selectdo
return(ticpr300.indt)
endselect
return(0)
}
function read.cpr300.cost.data()
{
select ticpr300.*
from ticpr300, ticpr010
where ticpr300._index1 = {:....
and ticpr300.cpcp refers to ticpr010
selectdo
on case ticpr300.cpcp
case cpcp.cu:
item.matc = item.matc + ticpr300.amnt
item.mmlc = item.mmlc + ticpr300.nuni
break
case cpcp.al:
. . . .
. . . .
. . . .
default:
item.mato = item.mato + ticpr300.amnt
item.mmlo = item.mmlo + ticpr300.nuni
endcase
endselect
}
Terry
mattan
14th July 2003, 08:33
terry,
thks, your code helps n cure my headaches.