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

Page-total in script

Former Member
0 Likes
585

hi,

i am working on a script.

in my output i have 3 pages in form

for each page i have to display page total

and on last page i have display the grand total.

Can any one tell me how shud i do it.

Rgds,

Fattesingh

4 REPLIES 4
Read only

Former Member
0 Likes
554

hi Gaikwad,

Try using <b>&sum&</b> statement in the footer of each page...

Read only

0 Likes
554

Just have a separated element for your total. You are probably looping a table in the print program and writing some detail lines. After that loop just write the Totals element. Doing this will put the totals on the last page of the sapscript.

Loop at itab.

call function 'WRITE_FORM'

EXPORTING

element = 'ITEMS'

window = 'MAIN'

EXCEPTIONS

others = 1.

  • Now write the SUB totals.

call function 'WRITE_FORM'

EXPORTING

element = 'SUBTOTALS'

window = 'MAIN'

EXCEPTIONS

others = 1.

endloop.

  • Now write the totals.

call function 'WRITE_FORM'

EXPORTING

element = 'TOTALS'

window = 'MAIN'

EXCEPTIONS

others = 1.

Read only

Former Member
0 Likes
554

Hi Gaikwad,

What you can do is in the sap script write an if condition on page no storing the page no and continuously keep on checking the page no condition before printing each line item.

Whenever you observe any change in the page no it means that the main window is complete, in the meanwhile keep adding the total in a variable and thus for each page change you will have page total calculated.

You can use system variable &page& for this.

Please Reward points if helpful.

Regards.

Sunmit.

Read only

Former Member
0 Likes
554

u must be looping at the internal table and u write_form fm to print the main window content. in the loop use a variable (for eg : sum) and sum up the values in each iteration. Then in the main window , in the text element which u use to display the data write

/: BOTTOM

  • &SUM&

/: ENDBOTTOM

this will be exeuted before the next page is called.