croezen
29th December 2010, 16:22
I have build an maintain session, but now i sometimes want to print a record.
i have created a button in the session and linked the report to the session. but when i try to print, i get the device selection, but then the error "can't read session or object"




choice.user.0:
before.choice:
if not marked then
message("no record marked")
choice.again()
endif
on.choice:
long i
for i = 1 to filled.occ
if not mark.table(i) then
continue
endif
restore.rcd.main(i)

rprt_open()
rprt_send()
rprt_close(1)

endfor
restore.rcd.main(1)
execute(find.data)

amitmmokashi
30th December 2010, 08:15
Hi,
I think you have forgot to compile the Report linked.
Regards,
Amit Mokashi

croezen
30th December 2010, 09:59
Thanks for your reply Amit, but too bad it's not that simple.
There must be someting i forgot, but wath?

ulrich.fuchs
30th December 2010, 10:18
Not sure any longer, if the same holds true for Baan IV, but in ERP LN the report selection process is only triggered in the choice.report section, not in other choices. So, when printing out of another section, I'm usually using this:

if choice.report (spool.report) then
if rprt_open() then
read.main.table()
rprt_close()
endif
endif


The choice.report ist the important part here, it triggers the dialog, where the user can select the device.

Hope that helps
Uli

sameer.don
30th December 2010, 10:19
You cna modify your script and call functions rprt_open(), rprt_send() and rprt_close() in choice.print.data

So what you can do is


choice.print.data:
on.choice:
rprt_open()
rprt_send()
rprt_close(1)

choice.user.0:
before.choice:
if not marked then
message("no record marked")
choice.again()
endif
on.choice:
long i
for i = 1 to filled.occ
if not mark.table(i) then
continue
endif
restore.rcd.main(i)
execute(print.data)
endfor
restore.rcd.main(1)
execute(find.data)

croezen
30th December 2010, 10:56
Thanks Sameer, that did the trick!
got it solved now