samsan
17th May 2013, 15:34
Hello,

I'm writing a Type 3 session with Main table. I added a query.extension to the script to filter the results.

Now I want to pop a message and close the session if no record is retrieved.

I wrote that code, it works but I think it could be better to use another way.

before.program:

zoom.from.usspe9201s000:
on.entry:
import("w.cous", w.cous)
import("w.codt", w.codt)
import("w.cotm", w.cotm)

query.extension = "usspe900._index2 = {:w.cous, :w.codt, :w.cotm} and usspe900.ddtm > 0 "

main.table.io:
before.read:
select usspe900.*
from usspe900
where usspe900._index2 = {:w.cous, :w.codt, :w.cotm}
and usspe900.ddtm > 0
selectdo
selectempty
message("nothing to treat")
end()
endselect


Thank you in advance for your help.

BaanInOhio
17th May 2013, 17:07
You might be able to skip the 'main.table.io' logic by simply checking the predefined variable for loaded occurrences. This will work if you always check before the first form becomes active (before program or zoom.from/on.entry). You will have to check differently if user actions can make the condition happen.



zoom.from.usspe9201s000:
on.entry:
import("w.cous", w.cous)
import("w.codt", w.codt)
import("w.cotm", w.cotm)

query.extension = "usspe900._index2 = {:w.cous, :w.codt, :w.cotm} and usspe900.

form.1:
init.form:
if (fattr.occurnr = 0) then
message("nothing to treat")
end()
endif

samsan
17th May 2013, 18:00
Thanks for your answer.

fattr.occurnr seems to be the number of occurences set in the form and not the number of records retrieved.

During debug, I get "fattr.occurnr = 10" even if I don't have result.

I try to find another internal variable.

BaanInOhio
17th May 2013, 20:14
Oops. I provided the wrong variable. It is filled.occ