ltannous
20th January 2003, 21:05
I would like to create an additional report in my session that prints the errors.
Example:
I have a session that prints sales items
select tdsls045.*
from tdsls045
where tdsls045.item = :tiitm001.item
selectdo
if tiitm001.item = tdsls045.item
and tiitm001.hatc = ""
then????
How can I send this result to another report?
Report 1 will not be printed becuase items were found with hatc = ""
Report 2 is error report that prints items with no hatc.
NPRao
20th January 2003, 22:00
You might have a flag to detect if that item was found or not.
If the item was not found then the first report is not printed and you can redirect that message Item ABC is not found to another report. You can use the spooler functions - spool.open() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_spooling_spool_open) so that the message shows up in a display browser or asks for a device.
lbencic
20th January 2003, 22:55
Yes, there are several steps to this.
1. Create both a regular report and an error report.
2. Attach both reports to the session. Put them in separate groups. See session for Generate Outbound (tdilc4201m000) on how to attach the 2 reports. (Report Button on form 1 of Maintain Sessions).
3. Write the Baan code to open the reports, instead of the standard open reports. Use the following:
open.report( 1, "", 1, language$, 1) |* for report 1 in group 1
open.report( 2, "", 1, language$, 2) |* for report 1 in group 2
These should go somewhere in the choice.print.data: / on.choice: section, replacing the standard generated commands. This requires the #include "itccom0010", a standard Baan function for report handling. If you do not have the source for that, you can use the long hand version of these commands with the spool.open as NP suggests above. I have found that Baan will issue customers the source for this include function as needed, however.
4. To print to a report, use the print.record(#) command, where # is the report number. In above,
print.record(1) |* to print to the first report
print.record(2) |* to print to the second report
Again, this requires the include, but there are corresponding spool.* commands that don't require the include. I just don't have examples!
5. To close the reports, just issue the close.reports(0), (1) or (2) as described in the close.reports help, all reports are closed, the number tells the option of if the user is issued a message or not,etc.
Hope that gets you going. Your example, then, finished would be
select tdsls045.*
from tdsls045
where tdsls045.item = :tiitm001.item
selectdo
if tiitm001.hatc = "" then
print.record(2) |* error report
else
print.record(1) |* normal report
endif
endselect
Could use some better construct - really don't need to do the select if the hatc is blank....open & close reports would go in the choice.print.data as in the standard generated version.
Good luck!
Edited: The commands require the #include itccom0010. The commands to do this without the include are the brp.*commands, not only the spool.* commands.
NPRao
21st January 2003, 00:18
Here is a example for spool -
if spool.open("","",1) then
spool.pr.line = hostname$()
spool.line()
select ttaad200.*
from ttaad200
where ttaad200._compnr = 000
order by ttaad200._index1
selectdo
spool.pr.line = ttaad200.user
spool.line()
endselect
endif
ltannous
21st January 2003, 07:06
I have added your suggestion to my script, and I can see both reports displaying on my device selection, but the proper report is not being called. I only want report 2 to display if there is an item with no hatc. If all items have hatc, then report 1 needs to print.
I think my open reports is not correct
choice.print.data:
on.choice:
open.report( 1, "", 1, language$, 1)
open.report( 2, "", 1, language$, 2)
if rprt_open
then read.main.table()
rprt_close()
else
choice.again()
endif
After my select statment and in my if statment, do I need a rprt_send()
lbencic
21st January 2003, 17:35
The rprt_* commands are the simplest construct of the report open / print / close commands. The open.report and print.record commands would replace the related rprt_* commands. So, no rprt_* commands. Without too much thought, something like the below will only open the error report if there are errors. I did not check syntax or compile....
choice.print.data:
on.choice:
if open.report( 1, "", 1, language$, 1) then
read.main.table()
close.reports()
else
choice.again()
endif
......
function read.main.table()
{
error.open = false
select tdsls045.*
from tdsls045
where tdsls045.item = :tiitm001.item
selectdo
if tiitm001.hatc = "" then
check.and.print.error()
else
print.record(1) |* normal report
endif
endselect
}
function check.and.print.error()
{
if not error.open then
if not open.report( 2, "", 1, language$, 2) then
break out with errors....
else
error.open = true
endif
endif
print.record(2) |* error report
}
ltannous
21st January 2003, 23:02
That seems to work well. How can I get just the error report to print if an error exists?
Now, the error report is printed and the regular reports with items that have no errors. I would like to not send the good report if any items are in error.
lbencic
22nd January 2003, 01:15
All the commands are valid from any function called from the choice print data section. If you only want the 'good' report if there are good records, you need another construct like I did for the error report...like.. check.and.print.valid()
Then, if either report is opened when you return from read main table, you can issue the close reports command.