cancel
Showing results for 
Search instead for 
Did you mean: 

Problem while printing a smartform having 2 templates

Former Member
0 Kudos

I am having a smartform having two templates. First template is printed for all the billing document types. But the second template is printed for a particular set of billing document types. Only first template has a footer in addition to line items1 and second template just has line items2. Both the templates are having line items, hence data to be printed in both the templates is stored respectively in two internal tables(ITAB1 and ITAB2). I'm facing problem in printing them.

a. If I take one main window and assign those two internal tables in that main window and based on some condition prints the data such that data of 1st ITAB1 is printed on template 1 and data of 2nd ITAB2 is printed on second template, then I am unable to print the footer of 1st template because I have given the condition on footer as "Only After End of Main Window" and as MAIN window is triggered only once so when the MAIN window is triggered on Template1, it goes to Main Window of Template2 and hence Footer is never triggered on Template1.

b. If I instead Take ITAB1 in Main window and ITAB2 in secondary window, and I give a Command in Main Window that after printing ITAB1, go to Template2, then again I face a probelm that if line items of ITAB2 is more than the page sapce, then they wont go to next page as I'm here (in this case) taking ITAB2 in a Secondary Window and not the Main Window.

Is there any way that I can print both the templates so that first template(line items1+footer) is printed always and second template(line items2) is printed only for a particular billing document types.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

HI friend,

Welcome to SDN.

Simple keep two main windows. Smartform allows you to keep two main windows so keep the template in two main windows and display.

One more thing you have mentioned that in your point b

"b. If I instead Take ITAB1 in Main window and ITAB2 in secondary window, and I give a Command in Main Window that after printing ITAB1, go to Template2, then again I face a probelm that if line items of ITAB2 is more than the page sapce, then they wont go to next page as I'm here (in this case) taking ITAB2 in a Secondary Window and not the Main Window."

Template is to print a structure not an internal table. It cant grow. Template is static it cannot grow. Also you have specified that you are using two internal tables for two template. Have you miss spelled the table as template or are you using the template only.

Because from your post i am able to find that only.

These are the things which you can do

1.So go for tables if your data grows.

2. Else use template if the data is static.

3. You can use the second logic because template wont grow.

4. If you are using tables then you can use two main windows and handle this issue.

I think this must solve your issue.

Please revert me back if you face any issues.

Thanks,

Sri Hari

Former Member
0 Kudos

Hi Hari,

Thanks for the reply... First of all I want to tell that by "template" i mean "layout" of the smartform. There are 2 "layouts" in the smartforms. So I am printing internal tables to the "Main Window" of the 2 layouts respectively.

I have followed the way that you have told me to have 2 Main windows in the respective layouts. Now I have two pages with two main windows. Let them be page1 and page 2. In the next page option of page1 I have given as page1 and similarly for page2 also I have given as page2. Also at the end of main window in page1 I have included a command node to goto page 2 from here.

But by doing the above approach, I'm able to print data on Layout1 . But I'm not able to print data of ITAB2 in the 2nd Main window(ITAB2) on Layout2. Evry other "secondary window" on Layout 2 is printed but 2nd main window is not printed at all.

Could you please tell me what approach I should follow.

Former Member
0 Kudos

HI friend,

Yes its true. We also faced the same issue when we were working on such a requirement yesterday.

But how i solved is. I created only a single Page and only one main window.

Print the data in the first internal table.

After printing the data give the command to break to next page. As we have given the next page as the same page a new page will be inserted.

After that display the data from itab2. So it looks like two pages but we can achieve this is single page itself.

Also performance wise its more efficient.

The control flows like this

Main window

Table1

Command

Table2

I think this will solve your requirement. If you face any issues in this please revert back to me i will help you.

Thanks,

Sri Hari

Former Member
0 Kudos

Hi Hari,

Thanks for your reply. Actaully I have 2 layouts. First layout has footer but second layout dont have any footer. If I follow your approach to print the data in the first internal tableITAB1 for layout1 and then giving a command to break to next page and printing ITAB2 on layout2, I am successful in printing the data.

But I'm faced with one problem that Footer(secondary window) of layout 1 is printed on all the pages of layout1(if there are more line items in ITAB1). But I need footer to be printed only at the last page of layout1. For that I have also given a condition in the footer(secondary window) that SFSY-PAGE = SFSY-FORMPAGES. But still footer is printed on all the pages of Layout1.

Please tell me what should I do furtheur so that footer is printed only at the last page of layout1.

nabheetscn
Active Contributor
0 Kudos

Hi Anurag,

What you can try is once the loop for ITAB1 ends you set a flag lv_footer equal to 'X' and thenon footer have this condition that it will print if LV_FOOTER = 'X'.

In this way your footer will get triggered when layout 1 ends. Now the second part is to stop it from triggering on all pages just inside the footer create a program line to clear the flag LV_FOOTER so that it should not print on further pages.

Anothe thinsg

By any chance can we combine the data of both ITAB1 and ITAB2 in one table. It will become then easier to handle it.

Let me know your inputs for the same.

Nabheet

Former Member
0 Kudos

HI friend,

As i said you are giving only one main window in page 1 and then printing the data in the internal table.

OK do like this,

At the fotter Output options there are two check boxes called At page break and at end of table,

Just check the single check box ie at end of table. That will do.

By default both the check boxes will be checked. So change that alone.

As both are At page break check box is checked it displaying at all pages.

I think this will solve your issue. If you still face any issues please revert back to me i will help you.

Thanks,

Sri Hari

Former Member
0 Kudos

Hi Nabheet,

I tried your method of cretaing a flag and setting it as 'X at end of loop of ITAB1. With this condition the footer is now only being printed at the last page of layout1. But there is 1 problem. All the precceding pages have "space" in the "footer area". In other words the footer area is empty for all the precediing pages. It should not be like this. All this empty space must be filled with line items. But this footer area is printed as empty space in all the pages except the last one(of layout1) where footer is printed.

Is there any way I can avoid this empty space at footer area.

Also ITAB1 and ITAB2 have different data.

Edited by: anurag15.khanna on Feb 9, 2012 7:25 AM

Former Member
0 Kudos

Hi Hari,

I'm unable to acheive the reqd functionality by checking the single check box - at end of table.

Is there some other way of acheiving reqd functionality

Former Member
0 Kudos

Hi friend,

Just now i replicated the same scenario as you did.

First checked both the check boxes and then executed the table. The footer is repeated at each page.

Second checked only "AT END OF TABLE" check box. Then the fotter was repeated at the end of the table.

Can you please again check and let me know have you done the same just do the changes by entering the smartform in change mode because sometimes if you go in display mode and then change it wont be changed so just enter the smart form in change mode do the changes and activate and check and see.

Just revert me if you face any queries. I will help you.

Thanks,

Sri Hari