Additional Packing Slip when printing invoice
Philipp Knecht
Rob wrote:
Hi.
Let me start by saying that we're using Report rendering engine as part of SAP's Coresuite components. And we are encountering a problem with a (rather complicated) report.
When printing Invoices (originating from SAP Business One), we have an optional packing slip. For this we have created a report consisting of 2 pages: page1 and page2.
page1 contains the invoice (and when printed can become more than 1 page). When the entire invoice (1 or more pages) has been printed the optional packing slip (page2) is also printed (also 1 or more pages).
Whether to print the packing slip is 'passed' by SAP as a parameter. In the template's GenerateScript we do this:
Code:
'Hide deliveryslip when required
If GetData("B1_Data.BusinessPartner.QryGroup3").ToUpper<>"Y"
page2.PaperKind=PerpetuumSoft.Reporting.DOM.PaperKind.Custom
End If
This causes page2 to be set to a 0 by 0 size page, in effect not printing it when when SAP passes anything but "Y". Actually, the parameter is just a 'customers property' whether they would like to receive packing slips.
So far so good. There is however a side-effect. The invoice contains a "Page x of y" textbox. The "y" value is the Pagecount number. This is where the problem lies.
A) When printing an Invoice-only document, the PageCount also contains the 'hidden pages'. Seems logical; though unwanted. I want to know the actual "Invoice pages"
B) When printing a document with invoice and packing slip, the "y" value also contains the packing-slip pages (this time not hidden) but again I want it to contain the actual invoice pages.
I have tried creating a new variable (InvPagecount), but I don't know where to increase it's value (InvPagecount+=1) so that only Invoice pages get counted and packing-slip pages don't.
I also tried creating a function GetHiddenPages which iterates through all the document's pages and counts pages with the "pagekind = custom" property. This doesn't seem to work, because the pagekind hasn't been set by then already.
* Maybe I need to set up the report in a different way (I would like to avoid subreports) or put some code in another place.
* I also tried toying with the IsDoublePass property but that also doesn't seem to help.
* I tried removing all pages from the document that are of type "page2" (using .GetType()) but removing pages from the collection causes an error in SAP (actually, this was expected because modifying a collection while iterating it is not allowed).
* I have been looking for a .Hide or .DontRender or .CancelRender property for a page object or similar properties/methods on the .Engine object but I can't find a way to hide a page other than setting it's pagekind to Custom (0cm by 0cm)
Sorry for the long post, I just wanted to be clear. Any questions (and ofcourse suggestions) are welcome.
Any help would be greatly appreciated.
Philipp Knecht
Hi Rob
I would solve it like that:
- Move the Packing Slip from Page2 to an separate layout.
(Copy the MarketingDINLayout with "Copy From" in the Layoutdef)
- Then Delete the second Page in the Invoice
- Then Make a copy query like "SELECT CASE WHEN PrintSlip='Y' THEN 1 ELSE 0 END FROM OINV WHERE DocEntry = [%DocEntry]" and save it into the SWA_LD_Copy Group.
- Then Open up the Invoice Printdefinition and add this Package Slip Layout and Select teh copyquery in the Copy - Column.
hth
Please sign in to leave a comment.
Comments
0 comments