Application Development and Automation 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: 
Read only

Total for two different types on same output

former_member386063
Participant
0 Likes
5,697

Hello experts,

I have a smartform in which for example:

If it shows an output of 5 pages.Out of 5 pages, 2 pages shows Type 3 output and 3 pages shows Type 53 output.The pages of Type 3 comes in sequence and then the pages of Type 53 in sequence (Or of Type 53 first in sequence then Type 3 in sequence). I want to have the grand total of "amount" at the end of page where Type 3 gets ended and the grand total of amount values at the end of page where Type 53 gets ended.

The example which I have presented here is of 5 pages. It can of any number of pages. So I want to count Type 3 pages and Type 53 pages separately with there respective Grand Total amount at respective end pages.

Please Help Experts.

Regards,

Titiksha

1 ACCEPTED SOLUTION
Read only

Private_Member_7726
Active Contributor
0 Likes
5,661

Hi,

You'd need two variables that will hold the numbers of last page for each type (l_page_type_3 and l_page_type_53, for example). I hope you are able to determine those... If not, one would need to see how you control the smartfrom page breaks to figure that out... Once you have figured out those, create final windows for totals output, with condition sfsy-page = l_page_type_3 and  sfsy-page = l_page_type_53.

cheers,

Jānis

26 REPLIES 26
Read only

Private_Member_7726
Active Contributor
0 Likes
5,662

Hi,

You'd need two variables that will hold the numbers of last page for each type (l_page_type_3 and l_page_type_53, for example). I hope you are able to determine those... If not, one would need to see how you control the smartfrom page breaks to figure that out... Once you have figured out those, create final windows for totals output, with condition sfsy-page = l_page_type_3 and  sfsy-page = l_page_type_53.

cheers,

Jānis

Read only

0 Likes
5,661


Hello,

Please tell me how to determine type 3 is ending in which page on runtime.

Regards,

Titiksha

Read only

0 Likes
5,661

In smartforms, use event to achieve this. In Tables node, first define "type" as your sort field and check the checkbox "Event on Sort End". In calculations tab, add your subtotals field.Then create a table line on event and place your variable in a text element. After subtotal text node, create program lines and clear the subtotal variable. you can search this further on SCN.

Regards

Read only

0 Likes
5,661

Hi,

Do you already have an existing smartfom to adjust, or are you building a new one..? How is the data for which you calculate totals structured - one internal table, the way Abhijit and Mehwish assume, or something else? If you already do have a form - what pages are defined (one page to output both types, or a separate page for each type?)

cheers

Janis

Read only

0 Likes
5,661

Hello,

I have an already existing smartform to adjust and separate pages for both the types. One internal table is displaying the total.

Regards,

Titiksha

Read only

0 Likes
5,661

Ok, then simply add a "dummy" Secondary Window on each page (or use the page header window, if there already is one in the form) and place the Abap code to assign current page number (variable sfsy-page) to l_page_type_3 or l_page_type_53 in  those windows. Don't forget to clear the l_ variables in Initialization

The Final Window will permit you to output the totals at a static position "at the end of page". If the data to be summed is processed via Tables node and the total needs to come immediately after the end of table, try the Mehwish suggestion.

cheers,

Jānis

Read only

0 Likes
5,661


Hello Mehwish,

I have done exactly as u said.

The thing is, it is already created smartform and total of every page is been done already by some other person in the footer part of table node.

I have to take those total into consideration, and have to do grandtotal at the end of respective types(Type 3 and Type 53).

I have done the things as u said, but if I create table line on event, it is created in Main area of table node. But I have to show the Grand total in the footer part below the total (which is already been done) at the end of respective types only.

Please help.

Regards,

Titiksha.

Read only

0 Likes
5,661

Hi,

Then, I'm afraid, the only way would be to use code in sorting events to clear and set the flag that controls the output of type total and placing the actual output of type total in table footer (after page total). Basically, you have to clear the flag at Event on Sort Begin, and you set the flag at Event on Sort End.

To place the code within sorting events you have to "wrap" it in the table line node... Just make sure there is only the code node assigned to some cell and no nodes doing any actual output. Such a line type will be executed but will not produce any actual output.

I still don't know how your smartform controls page break per type... but I´have created and attached  a simple SF with one page that illustrates the principle. This SF is using SPFLI as data table and CARRID as type. You would need some data in SPFLI to run it; program SAPBC_DATA_GENERATOR generates the data. The SF gets the data within INTIALIZATION of global SF data. Make sure there is at least 2 different CARRID selected... Hope you can figure it out; if not - just ask

cheers

Janis

Read only

0 Likes
5,661


Hello...

Thanks a lot for the help. Sorry for late reply.

Regards,

Titiksha

Read only

0 Likes
5,661

You're welcome; I know one day you'll help with that someone else

cheers

Jānis

Read only

0 Likes
5,661

Hello,

I need one more help.

Now I need to display the page numbers according to 'Type' (3 or 53).

Example: Page: ____ of Total _____ Pages. at the header of the every page.

If there are two pages for Type 3 and two Pages to Type 53 then:

Page: 1 of Total 2 Pages -----( for Type 3).

Page: 2 of Total 2 Pages -----( for Type 3).

Page: 1 of Total 2 Pages ------( for Type 53).

Page: 2 of Total 2 Pages ------( for Type 53).

Please Help.

Regards,

Titiksha


Read only

0 Likes
5,661

Hi,

Are there currently page counters somewhere in the form? If yes, I hope their output is not tied somehow to the table footer, because then we would need to find a way to calculate the total number of pages per type in advance...

cheers

Janis

Read only

0 Likes
5,661

Hello,

Nothing is been coded for this.

We need to do it ina separate window in header part.

Regards,

Titiksha


Read only

0 Likes
5,661

Hello,

Have you found out any solution for this?

I need to do it as early as possible.

Regards,

Titiksha

Read only

0 Likes
5,661

Hi,

Sorry, I couldn't attend to this yesterday evening, and this morning... I seem to be unable to solve this seemingly simple requirement...

I'll try to solve it tonight. I'm starting to think it may be better idea to split the table in driver program an call the form per type.

Edit in: Ok, I was overthinking it, trying to use SFSY-PAGE and SFSY-FORMPAGES variables...  I have now solved it in my example SF ZJBTT3 (see attached) as follows:

1) defined an internal table GT_PAGES, which will hold the page counters per type;

2) added an Abap node SET_PAGE_NUMBERS in data Table Footer->Total per page, which populates the type and TOTAL_PAGES columns in this table pro type ;

3) added a Final Window (will be processed when the rest of form logic is finished), where:

- in the Abap node GET_PAGE_NUMBERS:

- I'm reading first record in GT_PAGES; increasing the current page number, and, if the current page number = total page numbers per type, deleting GT_PAGES entry, otherwise modifying GT_PAGES with current page number;

- returning the GT_PAGES entry via GS_PAGES;

- in the text node I'm outputing GS_PAGES counters

I also changed the way ZJBTT3 handles table footers for the last page (via Flag in Table Footer definition, and not via explicit page break), because the previous version was producing extra white page at the end.

As always, it is important not to forget to clear/initialize the global variables in SF INITIALIZATION logic.

The reason why we need to use Final Window(s) here is - we will know the total pages per type only when the table processing is finished. Sorry for the somewhat chaotic description of algorithm - I hope you'll again figure out the principle from my example SF. If not - please ask again

cheers

Janis

Message was edited by: Jānis B

Read only

0 Likes
5,661

And thanks for the question, I learned quite a bit trying to solve it!

cheers

Janis

Read only

0 Likes
5,661

Hello,

It is showing the error in Global Definition which is shared in above image.

Error: No component exists with the name 'PRIMARY_KEY'.....

Regards,

Titiksha

Read only

0 Likes
5,661

Hi,

I developed it on ABAP 7.02 system, and you must be on a lower version then.

Try this attachment please - I  rewrote it while trying to use 4.70 syntax only and it works on my system. If it still doesn't compile, get rid of SORTED and KEY additions in the table altogether.. you'd probably need to adjust the READ and MODIFY statements as well then.

cheers

Janis

Read only

0 Likes
5,661

Hello,

The Version of smartform which u have given now is showing this Runtime error:

Assert Condition is violated.

Regards,

Titiksha

Read only

0 Likes
5,661

Hi,

Yes, thank you, the next version:

- added handling of empty data table! (I think that was the reason for runtime error);

- changed the way test data table is populated (will always be populated with three types);

- turned GT_PAGES into STANDARD table to handle sorting data table descending...

Does it work now..? If not, what is the SAP Basis Release of the system you are working on?

cheers

Janis

Read only

0 Likes
5,661


Hello,

The code which u sent is working properly. That was already been done in the code. But what you sent is the page numbers resetting according to 'TYPE'.

I want Total pages numbers resetting according to 'TYPE'.

For Example: Type3   Page 1 of 2

                     Type3  Page 2 of 2

                     Type 53 Page 1 of 3

                     Type 53 page 2 of 3

                     Type 53 page 3 of 3

I want this underlined page numbers on every page (Total page numbers for each 'TYPE').

Regards,

Titiksha

Read only

0 Likes
5,661

Hello,

Thanks for your active replies and the perfect solutions. Thank u so much.

I need the solution for my last reply. Its really urgent. M dependent on you. M stuck on it from past few days.

Please help.

Regards,

Titiksha

Read only

Abhijit74
Active Contributor
0 Likes
5,661

Hello,

I am sure that you are displaying type 3 and 53 inside a loop. So, what you can do is take two variables for type3 and 53. Inside your loop after displaying all of your cell you can create a program lines and there you can put sum3 = sum3  + itab-amount.

                           sum5 = sum5 + itab-amount.

You can also take a look into subtoal in smartforms.

Thanks & Regards,

Abhijit

Read only

Private_Member_7726
Active Contributor
0 Likes
5,661

Hi again,

Sorry, I'm confused... Just to reconfirm, I'm attaching the output of ZJBTT3 in my system as .gif image - is this not what you wanted..? Or does the output in your system look different?

cheers

Janis

Read only

0 Likes
5,661


Hello,

I got a bit confused in it.

Thank you so so so much for the solution.

It worked perfectly.

Regards,

Titiksha

Read only

0 Likes
5,661

Yesssss, I'm so glad it worked out If I encounter requrement like this, I'll probably be splitting the data table and smartform into two - the more ABAP nodes in the Form itself, the more difficult it is to understand the flow and maintain Form. If only SAP had made it possible to include whole Smartform in another Smartform, before they stopped developing it further...

cheers

Janis