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: 

hw to display subtotals in report..

Former Member
0 Kudos

hello abapers,

for example a classical report containing of 10 pages...

using aggregate operator sum() we can display the total of the particular field at the end of the report......hw to display subtotal of that infield in each page....

4 REPLIES 4

Former Member
0 Kudos

in ur code u need to write...

while printing....

val1 = val1 + field-value.

at end of page...

write:/ val1.

clear val1.

endat.

Former Member
0 Kudos

Hi,

While printing the report you use the LOOP AT and ENDLOOP. inbetween this take a new Global variale, and count the Total for every reocrd like

G_TOT = ITAB-FIELD + G_TOT.

then at the end of page write this G_TOT then clear that variable

Regards

Sudheer

Former Member
0 Kudos

Hi

You can use the number of line per page as logic each line you write this is the system variable SY-LINNO. if this variable is on the last line you can write the subtotal.

if you still have problem let me know.

Regards,

Lakshmikanth

varma_narayana
Active Contributor
0 Kudos

hi...

This is the Sample code for ur Requirement.

DATA : V_PGTOT TYPE I. "For Page total Calculation

TOP-OF-PAGE.

V_PGTOT = 0. "Initialize in every page

LOOP AT ITAB.

WRITE: <FIELDS>.

V_PGTOT = V_PGTOT + <YOUR FIELD>.

AT LAST.

SUM.

Write:/ 'Grand Total = ', itab-<field>.

ENDAT.

ENDLOOP.

END-OF-PAGE.

Write:/ 'Page Total = ', V_PGTOT.

reward if Helpful.