cancel
Showing results for 
Search instead for 
Did you mean: 

ONLY AT PAGE BREAK EVENT not working correctly

Former Member
0 Kudos

Hi,

I have an multipage Invoice docuement , wherein each record displays an amount field and at the end of the Inovoice document the total amount will be displayed.

My requirement was when the Invoice document is more than one page , then I need to display the Sub-total at end of each page, In order to do this I used ONLY AT PAGE BREAK EVENT option in the footer of the main window. I used to take add each record amount and used to display the same value at PAGE BREAK EVENT

However , The AT PAGE BREAK EVENT is trigerred only AFTER READING the FIRST RECORD of the next page , as a result of which the Subtotal amount it is displaying incorrect amaout as it considers the next page first record also.

Let me know how to sove this isse.

Consider each page displays three records only.. my output is displaying as below which is not correct.

PAGE 1

A 100

B 200

C 200

SUB TOTAL 600

PAGE2

D 100

E 400

TOTAL 1000

As seen above the Subtotal should be 500 but it is displaying 600 as it consders 100 of the next page also .

Kindly guide how to proceed.

Regards,

Senthil

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can use the subtotal option in the table.

check this:

[http://wiki.sdn.sap.com/wiki/display/ABAP/Togetsubtotalsoneachpagein+smartforms]

Former Member
0 Kudos

Thanks SAp_Wiz .., that blog helped in sub total in a very simple manner.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

You need to code it accordingly for displaying the sub-total.

Fix the number of records for each page.

Add your code for calculating the sub-total.(lv_tot = lv_tot + wa_tot) and for finding the tabix value.

Once it exceeds the number of recods,print the sub-total.

Jshree

Former Member
0 Kudos

You can write a simple logic to get the correct sub-total. Check below code - fine tune for other cases like if only 1 row in internal table...


  LV_SUBTOTAL = LV_SUBTOTAL + LV_VALUE.
  LV_VALUE = WA_DATA-FLD1.