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: 

How to get total pages in end-of-page event for report

Former Member
0 Kudos
271

HI friends

please tell me how to calculate total no. pages in report ,

suppose my report has 5 pages i want to display 1 out of 5 in end-of-page so please help me how to calculate total no. of pages of report

Thanks

Yogesh

10 REPLIES 10

Former Member
0 Kudos
73

hi,

in my opinion and experience, it's not possible define number total of pages before write.

Only in SAPscript it's possible know this number.

0 Kudos
73

Hi!

And in SAPScript, how can you determine all pages?

Thank you

Tamá

0 Kudos
73

SAPscript define automatically total number of pages... now i don't rember the field, but it's on SYST structure

Former Member
0 Kudos
73

Hi Yogesh,

There is no such specific way to do this........

but if you know how much lines you are going to print on one page then you can try doing this by....

1. Loop at internal table...

2. Calculate the number of lines to be printed...

3. get the number of pages you would require to print the total number of lines.....

4. use that variable to print the total number of page in END-OF-PAGE event.

let me know if you have any other doubt....

Thanks and Regards,

Kunjal Patel

Former Member
0 Kudos
73

hi

not sure of any variable that holds the total pages generated...just follow the logic in the above post and use sy-cpage or sy-pagno to get the current page

if helpful, reward

Sathish. R

Former Member
0 Kudos
73

hi,

Check Kishen Negi's post in this thread.

He has given an example code;

Regards,

Sailaja.

Former Member
0 Kudos
73

Try this, may be it works:

report zpage no standard page haeding line-count 60(5).

data: vtotpage type i,

vtemp(3) type c.

start-of-selection.

do 100 times.

write 😕 sy-index.

enddo.

vtemp = vtotpage.

do vtotpage times.

read line 1 of page sy-index.

replace '***' into sy-lisel with v_temp.

modify line 1 of page sy-index.

enddo.

top-of-page.

vtotpage = sy-pageno.

write :/60 'page', sy-pagno, '/', '***'.

This writes the toatl no of pages at the top. You can get an idea from this and modify it a little to display no of pages in end-of-page.

If it helps, award points

Former Member
0 Kudos
73

hi,

the same requirement is done by me this is not a only method.

1.end of page when u print list u store the sy-linno,sy-pagno at all where ever u print list.

2. find total pages at last using skip to line statement u put the cursor at there and modify the line with total number of pages.

then u achive this.

reward all helpfull answers

Former Member
0 Kudos
73

Hi..

Try this code..

REPORT zba_sdn LINE-SIZE 75 LINE-COUNT 36(2). .

DATA : BEGIN OF itab OCCURS 0, "Pages

sno TYPE i,

END OF itab,

w_sno TYPE i,

count TYPE i,count1 TYPE p DECIMALS 2,count2 type i.

START-OF-SELECTION.

DO 200 TIMES.

w_sno = w_sno + 1.

itab-sno = w_sno .

APPEND itab.

ENDDO.

DESCRIBE TABLE itab LINES count.

count1 = count / 32. <b>"<----


This 32 is (linecount - 4 ). for top of page (2) and end of page(2).</b>

count2 = count / 32.

if count1 > count2.

count2 = count2 + 1.

endif.

LOOP AT itab.

WRITE 😕 itab-sno.

ENDLOOP.

END-OF-PAGE.

ULINE.

WRITE: 'Page number ' , 55 sy-pagno, '/' , 65 count2.

Hope it will helps..

Reward Points if it useful means

Regards

Bala..

null

Former Member
0 Kudos
73

Hi Yogesh,

This is in continuation to my earlier reply. I modified the same code to suit to your requirement :

report zpages no standard page heading line-count 60(5).

data: vtotpage type i,

vtemp(3) type c.

start-of-selection.

do 100 times.

write 😕 sy-index.

enddo.

vtemp = vtotpage.

<b>end-of-selection</b>.

do vtotpage times.

read line 56 of page sy-index.

replace '***' into sy-lisel with vtemp.

modify line 56 of page sy-index.

enddo.

top-of-page.

vtotpage = sy-pagno.

end-of-page.

write :/60 'page', sy-pagno, '/', '***'.

I have tried it and its working fine.

Please award points to all helpful answers and close the thread if you are satisfied.