PearlJam
22nd July 2003, 18:28
Hello,

I was wondering if (and how) it is possible to fire up a new report from within a report (in some section or so).

Why I want this ?
We now print at the end of the month all our invoices. We want to start working with what we call 'overschrijvingsformulieren' (dutch). I don't know the english variant of this, just think of it as a small paper attached to an A4 paper with the amount and our account number on it. So the customer only has to fill in his account number, sign it, bring it to the bank and the invoice gets payed.

This special paper needs to roll out of the printer just after every invoice (same printer as invoice printer, different paper tray, same output bin). So I was thinking to open a report from within the invoice report to get the job done.
This does not seem to work (nothing gets printed, not even the invoice itself).
I tried with the following:

after.inco.1:
after.layout:
rep.id = brp.open.language("rtdsls440412345", language$, "D66", 0)
....
brp.ready(rep.id)
brp.close(rep.id)

Any thoughts ?

Regards,
Geert.

mark_h
23rd July 2003, 04:01
I am not sure if this is possible, but could you write a new subsession for this new report. Then in the report you might be able to export the necessary variables to zoom/activate the new session. Never done this but it might work.

I do seem to recall the question about running function servers from a report and I do believe this worked. In this case you would use the stpapi commands to call this new session from the report.

In either case I am not sure if the new report would come out between each invoice. I think these two options depend on the invoice program opening one report for each invoice, then as each invoice runs the new session is called.

Also just thought of this - why not add some after layouts on the invoice report, then you could create what ever layout you wanted and it would come after each invoice. You can always use the report script to find any data you might need.

Good Luck!

Mark

günther
23rd July 2003, 09:05
Hello Geert.

I started thinking about the data that normally need to be sent to the printer to do such a job. These data need to come from within one "file" or "data stream" (you could produce a draft test file) -- and I think that is the problem about your idea.

Whenever you use spool.open() ... spool.close() use one "file" or "data stream". So opening a second report would produce a different "data stream" with the problem to synchronize them.

Hmmh.

I remember I had done some tricky things some time ago ... (but I don't have access to that report any more.) I started debugging the report script and noted the way data get sent to the spool file. There is one function that does not increment the number of lines on the current page (I guess thats what you need), something like
>
> spool.pr.line = "my data"
> r_spool_line()
>
I remember that was much easier than a second report; don't spend too much time if that does not work.

Günther

kbartelds
23rd July 2003, 09:53
Hi Geert,

Solution is rather simple: you can use the invoice copy nr and make a detail specially for the second page only to be printed for nr copy. Set the input bin for that detail (and for the other layouts) and you're ready.

Regards,
Klaas

PearlJam
25th July 2003, 11:25
Thanks all for your reply.

Still some questions:
mark_h :
I've never worked with function servers before and I am also starting to think about the synchronisation. In tdsls4404 (customised) script, every orderline gets sent to the report. The report itself determines when to start a new page for a new invoice => probably not possible to print a new page in between the invoices.

kbartelds:
your solution sure looks simple. I could set a flag when the report prints the totals of one invoice, and then using that flag to trigger an after.field layout or something like that.
But how can I specify from within the report the input bin for just one layout ?

Thanks,
Geert.

kbartelds
25th July 2003, 12:13
You can use PC$ var to send output to specified bin, which bin is depending on your printer.

Regards,
Klaas

estotz
25th July 2003, 15:47
The easiest solution would be to have another after.report, or after.orno layout that printed the extra summary page (as mentioned before), but as this would be done in the same report you can't output one layout to one bin and one layout to another bin - the bin is the actual device. One report can only go to one device at a time.

If you need to direct it somewhere else, you'll need to modify the program script to open two reports at the same time.

If you don't have source, an alternate approach, although kind of bush, would be to simply have two reports attached to the invoice session. One report would be the detail, which you would direct to the top bin, and the other report would be the summary report - which prints the stubs. This would involve running the session twice though, with the first run doing the actual create of the invoices and the second run, reprinting those same invoices. Not a great solution, but possible.

A third solution would be to actually intercept the report script after compiling with bic ... editting the generated report code and add your own additional report opens, device selection etc and printing to the report. The data stream would be the actual temporary file that gets "sent" to the report from the program script. This would be very non standard and any changes to the actual invoice report would involve adding the code back in each time. Make sure if you follow this route to code the functionality in a few function calls to include so you can readd the code as easily as possible. To understand what you need to compile etc., look at the compile statements that go on when you compile a report.

PearlJam
25th July 2003, 18:10
estotz,

I think you are having a wrong idea of the problem. The output shouldn't be directed to different output bins, but the printer needs to take its paper from different input bins.

Summarization of problem:

tdsls4404m000: printing of invoices (heavily customized)
Let's say: 2000 orderlines for 50 different customers => 50 invoices.
Modifications in script: many reports are opened at the beginning (some customers want own invoice layout)
script of sls4404 reads all the lines, does some things with them and sends every line to the correct report.
For simplicity, let's say that all 50 customers have same invoice layout, so lines are sent to 1 report.

At the end of the invoice, a kinda like summarization page has to be printed, coming from a DIFFERENT INPUT bin, but has to come directly after the last page of the corresponding invoice.
So, after invoice 1 in output bin, we need summary page of invoice 1 in output bin, then invoice 2 in output bin, followed by summary page of invoice 2 in output bin, etc....

Problem with using an extra layout (eg. after.invoicenr.99) is that headers and befores and afters and footers are printed too. Should not happen. I think I can resolve this by using if...then... lattr.print = false statements and use a condition based on some sort of flag, which is set somewhere in the process ?

Main problem is: how to get paper from other input bin, without disturbing the correct order of the pages.

If I want to use the pc$ function, where/how can I use it in the report script ? Because if I compile the report manually with repgen6.1 and look at the output, I see lots of r_append_line() functions where those xx$ codes are used.

Can I maybe set the input bin in bwprint ?

Sorry for the lenghty post.

Geert.

estotz
25th July 2003, 19:26
Whether the bin you are talking about is an input bin (paper source) or an output bin (destination) either one being different is a DIFFERENT device in Baan.

I can not envision any scenario where you would be able to run one report and have another report place a summary page after the layout of another. One report can only print to one device. If you want two devices (which you need because of your input bin scenario), then whatever finishes and gets spooled to the printer first is what is printed first. You would either get all the invoices first and then all the summaries, or all the summaries and then the invoices.

You could loop and run one report, then the other, then the first report, then second for each customer, but that would be very slow and cumbersome.

Here's what I suggest, and I have not done this before, but it could be done. This suggestion will assume 1 report, because you need the summary pages in the correct places.

1. create a customized table that has the customer and what layouts they want in their invoice - your invoice report or program script will determine what layouts to print by the customer.

2. create a new device driver that uses a font change or initialization command that will have the correct escape sequences to tell the printer which input bin is to be used. e.g. code font9 to select from bin 1 and font10 to select from bin 2.

3. in the main invoice report, the initialization command (set to font 9) in a layout will choose input bin 1

4. in the summary layout, the initialization command (change of font to font 10) will take output from bin 2.

In the scenario above the bin changing is done at the printer level, rather than logic in your Baan report(s).

Alternatively, you could write a report that generates HTML code that simulates your pre-printed forms. I have done this for a couple of customers for their invoices and purchase orders as they wanted logos and fancy looking invoices on plain paper. The report could only print on one type of paper, so you could not intersperse legal and letter, just one type of paper.