Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Printing last page in smartform

former_member367551
Participant
0 Kudos

Dear experts,

In my smartform, I have 3 pages - FIRST, NEXT and LAST.

The FIRST and NEXT pages are quite similar with one another - both their MAIN windows are exactly the same.

(If the line items are not able to fit fully in the FIRST page, the remaining line item data will be shown in the NEXT page.)

The LAST page contains its own MAIN window - this window only displays several plain, standard texts (nothing fancy / complex).

How can I force the LAST page to be printed as the final page in my smartform output? I am currently unable to do this

I have searched through the forum threads, but nothing works for me so far.

Further info on the pages of the smartform:-

The next page of FIRST = NEXT

The next page of NEXT = NEXT

The next page of LAST = (this is left blank)

For both the FIRST and NEXT pages, there are a few other secondary windows that are placed below the MAIN window.

These secondary windows are shown only conditionally.

The LAST page only contains one window - MAIN window.

(I have tried adding a command as the last node within the MAIN window of the NEXT page - to "go to FINAL page" "only after end of MAIN window", but this did not work for me.)

Please help; any inputs will be much appreciated.

Many thanks~

1 ACCEPTED SOLUTION

Private_Member_7726
Active Contributor
0 Kudos

Hi,

When you write "the LAST page contains its own MAIN window" is it really another window, and not just a copy of the same MAIN window from pages FIRST and NEXT? If yes, that is a problem - a form can contain only one MAIN window.


Put all your LAST page content in the first main window and add the command to go to LAST page before the content.

To make matters more confusing... an empty second main window on LAST page (as long as it is the same width as first main window) would also work... Something like this:

So the rule is actually: one main window with content per form. However, I'd not use this "feature"... What if someone at SAP decides one day to really enforce "one main window per form" rule?

cheers

Jānis

37 REPLIES 37

former_member206650
Active Participant
0 Kudos

change command of next page to The next page of NEXT = last...

Former Member
0 Kudos

Hi

First right click on the window we find the command option there we just mention the NEXT PAGE there mention the PAGE N.

Regards

Karthikeyan RV

sunil_mani
Active Participant
0 Kudos

Hi Deborah,

    I have tried adding a command as the last node within the MAIN window of the NEXT page - to "go to FINAL page" "only after end of MAIN window", but this did not work for me.


This condition never gets satisfied as you have main window in your last page also. Please change the condition to someother one. You have to describe number of lines in your internal table, then use that as a condition to call the next page or try to have someother condition to call the last page based on your requirement.

Private_Member_7726
Active Contributor
0 Kudos

Hi,

When you write "the LAST page contains its own MAIN window" is it really another window, and not just a copy of the same MAIN window from pages FIRST and NEXT? If yes, that is a problem - a form can contain only one MAIN window.


Put all your LAST page content in the first main window and add the command to go to LAST page before the content.

To make matters more confusing... an empty second main window on LAST page (as long as it is the same width as first main window) would also work... Something like this:

So the rule is actually: one main window with content per form. However, I'd not use this "feature"... What if someone at SAP decides one day to really enforce "one main window per form" rule?

cheers

Jānis

0 Kudos

Thank you, everyone, for all your inputs. I really appreciate it a lot.

I've made further adjustments to my smartform, but unfortunately, the last page is still not shown.

Jānis, yes, the MAIN window of the LAST page (named as LAST) is not a copy of the MAIN window from the FIRST or SECOND pages. Any idea on how I can resolve this further?

FYI, the LAST page must only be shown whenever the flag data variable, GV_PRINT_FINAL_PG is set as 'X'. The value of GV_PRINT_FINAL_PG is determined from within the smartform's Global Definitions --> Initialization.

This is what I've done, but it's still not working:-

Changed the page attributes

The next page of FIRST = NEXT

The next page of NEXT = LAST

The next page of LAST = (this is left blank)

Moved the contents of LAST page into the MAIN window of the FIRST and NEXT pages

Cut and paste the contents of LAST page's window into MAIN window of FIRST and NEXT page.

Place the contents within a folder

Above the folder, add a command node that says "Go to page LAST"

Adjusted the MAIN window of the LAST page

Set the width of this MAIN window of the LAST page to be the same as the width of the MAIN window from the FIRST and NEXT pages

Ensure that the MAIN window of the LAST page is now empty

How else can I resolve this issue? Please help~

Thanks much, once again.

0 Kudos

0 Kudos

Hi Deborah,

    Please uncheck Only after end of main window. It will call your last page.

    

0 Kudos

Hi,

Sunil is right, I believe. The help on SF "events" says:

only after end of main window

Output starts only after all nodes within the main window are processed. It makes no sense to activate this event for a node within the main window, since it would never be printed.

In your case, the command will not be processed as long as this event condition is set. Why do you think you need this extra condition for command? Checking whether the GV_PRINT_FINAL_PG variable is set should be enough, isn't it?

cheers

Jānis

Edit in: and thanks for providing really good and extensive information - it makes it so much easier to troubleshoot problems when all the info is there

0 Kudos

The extra empty main window (LAST) should work. I would, however, just delete it and copy over MAIN to the LAST page as well - whether LAST works or not. You are already controlling the output of last page contents using GV_PRINT_FINAL_PG .

You can still adjust positioning, height, borders and shading for the copy of MAIN on LAST page (without disturbing the attributes on FIRST and NEXT). Only the width of MAIN must remain the same throughout the form.

cheers

Jānis

0 Kudos

Hi Sunil & Jānis,

Thanks for your inputs.

I've just unchecked / disabled the option, "Only after end of main window" in the Command node.

Now, two pages will be shown in my smartform output.

The first page contains the correct data, but the footer windows (TOTALS, HOW_TO_PAY, BANK_DETAILS) below the MAIN window are all not shown

And, only a blank page is shown in the second page.


This is still incorrect


What can I do?

0 Kudos

Hi,

Hmm... What are the conditions on the footer windows?

Would it not be against the company rules, if you download as XML and attach here the whole form (or at least the FIRST Page).

cheers

Jānis

0 Kudos

0 Kudos

Should I change the window in the LAST page to the type, final window instead?

0 Kudos

Hi Jānis,

Here's the link to the XML file, containing just the first page. Hope this is sufficient.

Z_BILLING_SMARTFORM.xml - Google Drive

Thanks for all your help~

0 Kudos

Hi,

Thank you, I'll have a look at it tonight (can't access the google drive from office). Final windows will not help, I'm afraid. If the contents of LAST page would always fit on one page then we could use secondary window. Otherwise, we would need to use a flag variable to control the footer windows instead of "After end of main window" condition (clear the flag in Initialization, set the flag just before doing page-break command...

cheers

Janis

0 Kudos

Appreciate your help on this~ Thanks a lot~

0 Kudos

Hi,

I really don't like adding another flag and making even more conditions on TOTALS, HOW_TO_PAY and BANK_DETAILS, but I can't come up with a better idea, so...

- define global flag GF_FIRST_OR_NEXT_FINISHED type XFELD

- clear the flag in initialization;

- set the flag before page break via ABAP node

- add the flag in TOTALS, HOW_TO_PAY and BANK_DETAILS conditions:

( IS_BIL_INVOICE-HD_GEN-SHIP_COND = 'Z2'

OR                 

IS_BIL_INVOICE-HD_GEN-SHIP_COND 'Z2'

IV_CURRENT_PG = IV_TOTAL_PG )

GF_FIRST_OR_NEXT_FINISHED INITIAL


- get rid of 'Only After End of Main Window' flag on TOTALS, HOW_TO_PAY and BANK_DETAILS

Setting the flag and page break command can be wrapped in a folder. You could also trigger the page break directly from Abap node, as shown in the attached form.

Those IV_CURRENT_PG = IV_TOTAL_PG conditions are bothering me a little (because I don't know what the driver program is trying to accomplish there), but if it was working before it should still work after adding flag.

You are getting rid of all those nodes with 1 = 2 conditions when you are done with the form, aren't you

cheers

Jānis

P.s. There seems to be a little 'bug' in SF runtime - if there are secondary windows on the page where explicit page break is processed, processing the secondary windows sets the SFSY-PAGENAME back to the name of the page that was finished by page break command... Edit in: and SFSY-WINDOWNAME as well... Can be set right, if necessary, by PERFORM update_system_fields IN PROGRAM SAPLSTXBC (until SAP changes something in SF runtime, that is...)

Message was edited by: Jānis B

0 Kudos

Dear Jānis,

Apologies for the late reply, as I have not been well and have just only looked at this now.

Thanks a lot for checking this for me, appreciate it.

"Those IV_CURRENT_PG = IV_TOTAL_PG conditions are bothering me a little (because I don't know what the driver program is trying to accomplish there), but if it was working before it should still work after adding flag."

This had to do with another requirement for cross-docking invoice scenario - where specific line items are only shown in a page separately for the corresponding delivery number and ship-to-party address. Because of this scenario, I had to make changes to the print program as well - hence the condition, IV_CURRENT_PAGE = IV_TOTAL_PG in the smartform.

"You are getting rid of all those nodes with 1 = 2 conditions when you are done with the form, aren't you "

Yes - this smartform was originally copied from another older existing smartform, and those '1=2' conditions were for unwanted windows / elements from the older existing smartform. These will be removed eventually.

I will try to adjust the smartform further - and will let you know the outcome.

Many thanks once again, for all your help~~

0 Kudos

Dear Jānis,


Attached here is the whole smartform, containing the FIRST, NEXT and LAST pages.


I've tried adjusting my smartform as per your advice, and tested the output as well.

I think this is the best state for the smartform so far, and I thank you for your advice and input.

However, the last page is still not shown -- this is currently shown as a blank new page.


Might this be easier to resolve right now? Is there something else that I need to add on further?


Please please help~


Would really appreciate it much~


In addition, just like how you've done in your smartform, I've also changes these page attributes in my smartform:-


The next page of FIRST = NEXT

The next page of NEXT = NEXT

The next page of LAST = LAST


Hope I'm going on the right track, towards resolving the issue.



Deborah

0 Kudos

Dear Jānis,

Due to file size limitation, I was not able to upload the complete XML file earlier on. Apologies for this.

Attached here is the XML file - containing the FIRST page.

To create the NEXT page, you will just need to copy the FIRST page and rename the newly created page as NEXT.

Regards,

Deborah

0 Kudos

Dear Jānis,

Attached here is the LAST page of the smartform.

Regards,

Deborah

0 Kudos

Hi,

Got the From, thank you. From the looks of it, all you have to do now is:

- drag the LASTPAGE_CONTENTS folder back over into MAIN window, right after the PAGEBREAK;

- put a gv_print_final_pg = 'X' condition on the folder.

If something still doesn't work, I'll look at in the evening - having lots of meeting today

This may feel somewhat counter intuitive - how come SF composer doesn't process the folder located in LAST window and how can it even process it, if it's after the PAGEBREAK and even if the main window of LAST page is not called MAIN anymore, but that's how the Smartforms are built... There should be just one main window where contents are located, and this MAIN windows can span all the pages. The composer would take just the positioning, shading and borders and borders attributes from LAST window and continue outputting the contents of MAIN on LAST page...

cheers and hope it works,

Jānis

0 Kudos

Thank you so much for all your effort and help here, Jānis..

The problem is resolved by changing the type of WINDOW in the LAST page to SECONDARY window (instead of MAIN window type). I didn't need to do the following too:-

- drag the LASTPAGE_CONTENTS folder back over into MAIN window, right after the PAGEBREAK;

- put a gv_print_final_pg = 'X' condition on the folder.


This may feel somewhat counter intuitive - how come SF composer doesn't process the folder located in LAST window and how can it even process it, if it's after the PAGEBREAK and even if the main window of LAST page is not called MAIN anymore, but that's how the Smartforms are built... There should be just one main window where contents are located, and this MAIN windows can span all the pages. The composer would take just the positioning, shading and borders and borders attributes from LAST window and continue outputting the contents of MAIN on LAST page...

Hmmm, could this be due to the earlier MAIN window of the LAST page is completely different / unique compared to the MAIN windows of the FIRST and NEXT pages?

Regards,

Deborah

Jelena
Active Contributor
0 Kudos

Deborah, we use the same approach as Janis mentioned to print terms and conditions as the last page. The LAST page only has T&C, it doesn't have any other items. It does have one big MAIN window and it's exactly the same window as on the first two pages, see the screenshot below (you can see a bit of layout too - just one big MAIN).

But we don't have the additional secondary windows that must be printed after MAIN. Maybe you could move the Go to command and text element to the very last window in your form? I'm not sure if in this case on the LAST page you'd need MAIN window or the same as last window, but it's an easy test.

It's important to understand the flow of the form. It will continue printing until information in MAIN runs out (that's why we're able to add another page by including command in MAIN window). After that other items marked 'after end of main window' will print. But after that form ends and there is nothing more, so we can't really make it print all items 'after end of main' and then something else.

If all else fails you might want to explore an option of printing two separate forms.

0 Kudos

Dear Jelena,

Thank you for looking into this, and for sharing your experience too~

It really helps a great deal to know I'm not in this alone

"Maybe you could move the Go to command and text element to the very last window in your form?"


I've tried this earlier on in my smartform, but I couldn't -- because a command node containing a 'page-break instruction' can be inserted only within the MAIN window (this will not be allowed in other types of windows). And in my case, the last window in my form is a secondary window -- I need to display these secondary windows 'after the end of MAIN'.


Again, thank you for your inputs, anyhow. Appreciate it much.

sunil_mani
Active Participant
0 Kudos

Hi Deborah,

   

Issues are with your conditions that you placed on the folder LASTPAGE_CONTENTS, please remove the conditions on it and try to execute your form. It should call your last page with last page contents defined in the main window of first page.  I tried one example for you with same logic. Please find the screenshots below.

My Page 1:

Template 1 below command is like folder Last Page in your case. This template has text Template.  And I created window3 which is like your TOTALS secondary window. I didn't put any condition on this window. This window should be displayed only on page1 for me. It has a text as First Page.

My Page2: ( Next Page in your Case )

It is same as my first page with little difference. I have created a secondary window window1 which has text Second Page.

    

My Page3 ( Last Page in your Case 😞

My Main window in page3 doesn't have any contents defined same as your case. But additionally i created a secondary window which has text  "Last Page''.

My Output:

Page 1:

Page2:


My lineitem follows to next page as well so it will be same as page2.

Last Page:


Text Template got displayed on the last page, which i have defined in the main window of first page. But i didn't any condition on the template.

Hope this helps for you.

0 Kudos

Dear Sunil,

I'll try this out and let you know how it goes~

Thanks a lot for this, too~

0 Kudos

Dear Sunil,

The last page is only required to be printed out for certain customers, depending on the customer's industry.

I've tried to remove all conditions from the  LASTPAGE_CONTENTS -- yes, this worked for displaying the last page finally. However, the secondary windows (TOTALS, HOW_TO_PAY and BANK_DETAILS) that are meant to be displayed 'after end of MAIN window' were not shown at all

This only works perfectly for invoices of certain customers that fit the requirement.


However, if I test this with invoices for other customers that do not fit the requirement (last page should not be printed out), then the contents of the last page is still printed out on the first page and next page in an 'overlap' manner. This is incorrect -- so, to fix it, I had to insert the conditions that I had inserted earlier on in the LASTPAGE_CONTENTS.


Is there something else that I can do to resolve this?

P/S:

In your example, WINDOW3 does not have any condition attached to it, so perhaps this is why it could work perfectly for that specific scenario.

0 Kudos

Hi Deborah,

    

     Even i tried by placing conditions on my secondary window ( WINDOW 3 ) and on template of last page, it is working fine for me.  Please check whether your conditions are getting satisfied in debug mode.

0 Kudos

Yes, Sunil, it finally worked when I changed the window in the LAST page to SECONDARY window type (it was a MAIN window type earlier on).

Regards,

Deborah

VijayaKrishnaG
Active Contributor
0 Kudos

Hi Tan,

The problem is NOT with triggering LAST page, even though LAST page has been triggered, that data will not be displayed. Why because, in smartfrom only one MAIN window will be executed, and the MAIN window in other pages will not be executed.

In your case NEXT page is copy of FIRST page, so in both the pages, the MAIN window is common. So, in this case there will not be any problem. But in LAST page, MAIN window is diffrent and this will not be executed.

If you want to display data, make that window as SECONDARY window.

Regards,

Vijay

0 Kudos

Hi Vijay,

Thanks for this~ It works right now

Regards,

Deborah

0 Kudos

Hi Deborah,

What's working, whether Secondary window or Main Window???

Regards,

Vijay

0 Kudos

If you want to display data, make that window as SECONDARY window.


I changed the window type in the LAST page to secondary window type, and it worked.



Regards,

Deborah

0 Kudos

Deborah,

Oh okay.. got it.

0 Kudos

Hi,

Yes, as long as the contents of the LAST fit on one page, it's the best solution.

cheers

Jānis

former_member367551
Participant
0 Kudos

Heartfelt thanks and appreciation to everyone who has contributed your ideas and inputs to the issue discussed here~

Regards,

Deborah