Skip to Content
0
Former Member
Sep 27, 2011 at 07:43 AM

SMARTFORM printing - 2 copies of page 1 and 1 copy of page 2

581 Views

Hello,

I have a requirement to develop a SMARTFORM with 2 pages, whereby both the pages have different layouts. Page 1 contains production order data and can overflow to multiple pages, while Page 2 contains confirmation ticket data, which will only be one page. I managed to trigger Page 2 by using Command 'Go to New Page' in the Main window of Page 1.

The issue that I am facing is that they want Page 1 to always be printed as 2 copies, and Page 2 should only have 1 copy printed. I am using TDCOPIES to pass in the number of copies from the print program. I have tried two alternatives, but both have issues:

Method one:

I created two pages in the form - Page 1 and Page 2. Page 1 has Command to go to Page 2 in the Main window, after the Items data loop. I defined the Window in Page 2 as Copies Window and selected radio button 'Only Original'. When I test this, for the Original Copy, I get Page 1 printed (as many pages as the data overflows) and Page 2 is printed. For the Duplicate Copy, Page 1 is printed correctly again and I get a blank page at the end (which I think is Page 2 without the text).

I changed the option by selecting radio button 'Only Copies - Copies Identical', and this reverses the output as mentioned above. Page 2 comes out as blank page for the Original copy.

I can't seem to figure out how to set a condition so that the Command to go to Page 2 triggers only for the Duplicate copy because in Main window SFSY-COPYCOUNT will always be 1. And Main window is processed last so even if I set a flag/counter in another Copies window on Page 1, it doesn't work either.

Method two:

I created three pages in the form - Page 1, Page 2 and Page 3. Page 2 has the same layout as Page 1 (to act like the duplicate copy). In Initialization, I created an internal table to store page names (1,2).

In Page 1: In the Main window, I create a loop against the Page Names internal table. Inside this loop, I create a loop against the Items data table. At the end of the Items data loop (still inside the Page Names table loop), I create a Command to go to Page 2, with Condition that current page name = 1. This works and Page 2 gets triggered correctly.

In Page 2: In the Main window, I create a loop against the Page Names internal table. I set the Sort Criteria for this loop to sort Page name in descending order, so that the loop starts from Page Name = 2. Inside this loop, I create a loop against the Items data table. At the end of the Items data loop (still inside the Page Names table loop), I create a Command to go to Page 3, with Condition that current page name = 2. This however does not work and when I debugged, it seems like the Command doesn't get triggered here. Only Page 1 and Page 2 are displayed in the output.

If anyone has any ideas on how to solve the issues on either one of the methods above or if you have any other alternatives that have worked for you, please do share with me.

Additional info: this smartform will be triggered from a std transaction using output type.

Thanks in advance!!!