monica1
17th June 2005, 12:13
I write this code, but it show me all the records no only the :num.mov I select. Where is the problem?


before.program:
import("tfcmg001.bank", tfcmg001.bank)
import("caso", caso)
import("num.mov", num.mov)
import("fecha.f", fecha.f)
import("fecha.t", fecha.t)
import("mi.mes", mi.mes)
import("year", year)

|** preparamos la query.extend
query.extend.select("tfcmg001.*", EXTEND_APPEND)
query.extend.from("tfcmg001", EXTEND_APPEND)

query = "tfcmg001._index1 = {:tfcmg001.bank} and " &
"tfcmg001.bpid.l = cacmg100.bank and " &
"tfcmg001.bano = cacmg100.bano and " &
"tfcmg001.badr = cacmg100.ofic "
if caso = 1 then
valido = tcyesno.no
|* programado en el main.table.io/ after.read.
endif
if caso = 2 then
query = query & "and cacmg100.date inrange :fecha.f and :fecha.t "
endif
if caso = 3 then
fecha.f = date.to.num(year, mi.mes, 1)
mi.mes = mi.mes + 1
if mi.mes > 12 then
mi.mes = 1
year = year + 1
endif
fecha.t = date.to.num(year, mi.mes, 1)
fecha.t = fecha.t - 1
query = query & "and cacmg100.date inrange :fecha.f and :fecha.t "
endif
query.extend.where(query)

main.table.io:
after.read:
if caso = 1 then
select cacmg100.bank, cacmg100.ofic, cacmg100.bano, cacmg100.date:date,
cacmg100.conc:conc, cacmg100.conp:conp, cacmg100.docu:docu
from cacmg100
where cacmg100._index1 = {:cacmg100.bank, :cacmg100.ofic, :cacmg100.bano}
order by cacmg100._index1 desc
as set with :num.mov rows
selectdo
if cacmg100.date = date and cacmg100.conc = conc and cacmg100.conp = conp and
cacmg100.docu = docu then
valido = tcyesno.yes
endif
endselect
if valido = tcyesno.no then
skip.io("")
endif
endif



If I want is if caso = 1 show only a concret number of records, if caso = 2 I only want to show the records between 2 dates, and if caso = 3 I want to show the record in a concret month.
The caso = 2 and caso = 3 works well but caso = 1 show me all the records.

Can you help me?
Thank you in advance,

mark_h
17th June 2005, 14:59
Not a baan 5 expert, but I think you need to move the caso=1 functionality up into the before program section. Once you have hit the after read piece the program has already pulled all the records. I am not sure you can use the "as set with x rows" in the query.extend, but it is worth a try.

monica1
17th June 2005, 15:02
I find finally the problem I write valido = tcyesno.no the first line in main.table.io/after.read and now it works.

Thank you very much