veyant
5th June 2003, 15:53
Hi guys,

I am facing problen that where should i insert rprt_send() command in the script as if i insert it before close of function, it only prints the last record. but if i put it before last Endselect then it prints one record n number of time. can somebody help me in getting the problem right as where should i place rprt_send() so that it only print properly. Code is given below.

function read.main.table()
{

select tirou102.*, tiitm001.*
from tirou102, tiitm001
where tirou102.mitm>=:mitm.f and
tirou102.mitm <= :mitm.t and
tirou102.mitm = tiitm001.item
order by tirou102.mitm
selectdo
t2 = tiitm001.dsca
t3 = tirou102.cwoc
run1 = tirou102.rutm
item = tirou102.mitm
seqn= tirou102.opno
select tirou102.*
from tirou102
where tirou102.mitm = :item and
tirou102.opno > :seqn
selectdo
calculate.runtime()
endselect
| rprt_send() |it prints each rcord 10-12 times.
endselect
| rprt_send() | it prints last record only
}

function calculate.runtime()
{
if (tirou102.opno=20 and tirou102.seqn=1) then
run2=tirou102.rutm
T4=tirou102.cwoc
endif
if (tirou102.opno=30 and tirou102.seqn=1) then
run3=tirou102.rutm
T5=tirou102.cwoc
endif
if (tirou102.opno=40 and tirou102.seqn=1) then
run4=tirou102.rutm
T6=tirou102.cwoc
endif
if (tirou102.opno=50 and tirou102.seqn=1) then
run5=tirou102.rutm
T7=tirou102.cwoc
endif
if (tirou102.opno=60 and tirou102.seqn=1) then
run6=tirou102.rutm
T8=tirou102.cwoc
endif
if (tirou102.opno=70 and tirou102.seqn=1) then
run7=tirou102.rutm
T9=tirou102.cwoc
endif
if (tirou102.opno=80 and tirou102.seqn=1) then
run8=tirou102.rutm
T10=tirou102.cwoc
endif
if (tirou102.opno=90 and tirou102.seqn=1) then
run9=tirou102.rutm
T11=tirou102.cwoc
endif
if (tirou102.opno=100 and tirou102.seqn=1) then
run10 = tirou102.rutm
t12=tirou102.cwoc
endif
if (tirou102.opno=110 and tirou102.seqn=1) then
run11 = tirou102.rutm
t13=tirou102.cwoc
endif
if (tirou102.opno=120 and tirou102.seqn=1) then
run12 = tirou102.rutm
t14=tirou102.cwoc
endif
if (tirou102.opno=130 and tirou102.seqn=1) then
run13 = tirou102.rutm
t15=tirou102.cwoc
endif
if (tirou102.opno=140 and tirou102.seqn=1) then
run14=tirou102.rutm
t16=tirou102.cwoc
endif
}


As i stuck here only due to this problem.
Can somebody let me know the solution

VEYANT

mark_h
5th June 2003, 17:02
First I would use an alias for the second select and put the rprt_send after it. It maybe that the second select is causing problems for the first select on tirou102.

Mark

nick_rogers
5th June 2003, 17:29
I agree with Mark, most likely the table pointers are getting mixed up, either use an allias or make the second select in its own function with its own table declaration (pass it the item and seqn) and return the run2 and T4 values or make them global vars. Then leave the rprt_send() in the function read.main.table()
selectdo block.

avpatil
5th June 2003, 21:30
Hi,
I didn't get whay u need the second tirou102. What exactly do you want?

Arvind

morpheus
9th June 2003, 10:13
select tirou102.mitm
from tirou102
where tirou102.mitm inrange :mitm.f and :mitm.t
and tirou102.mitm refers to tiitm001
group by tirou102.mitm
selectdo
select tirou102.*
from tirou102
where tirou102.mitm = :tirou102.mitm
selectdo
calculate.runtime() |Change the function if "opno = 10" is required
rprt_send()
endselect
endselect



Regarding variables (t1, t2, etc.), report script can be used.

Hope this helps.