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: 

can anyone help me with this question?

Former Member
0 Kudos

hi experts

Now I am writing a report and I have to get the number of how many pages is going to be displayed.

How can I know this? I know there is a system variantsy-pagnocontains the current page number, but is there any variant that can tell me how many pages are there?

many thanks...

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

the page number itself is the number of pages we have right. so we can use that.

7 REPLIES 7

Former Member
0 Kudos

Hi,

If you are using smartform to print your data..than u can use system variable SFSY-FORMPAGES to get the total number of pages..

Regards,

Smit

Former Member
0 Kudos

Hi,

the page number itself is the number of pages we have right. so we can use that.

0 Kudos

Dear chandrika and Smit

I am not using Smartform, I am just writing a report using SE38, and then write out the result.

e.g. the result will be printed in 3 pages, how could the program know how many pages should be needed?

I just want to print like: page 1/3 2/3 3/3...

0 Kudos

Hi,

You declare a variable and assign sy-pagno to it after writing the data .

the variable will give you the total number of pages

regards

padma

0 Kudos

Hi,

you told that sy-pageno is the system variant which stores the current page number.

store that value into a variable and while printing,

write the value.

if u want to write as 1/3,2/3...

take a variable with 0 as initial value.

if variable < pagenumber value

write variable/pagenumber.

increase the variable( variable+1)

endif.

0 Kudos

REPORT Y_WA no standard page heading line-count 60(5).

data: v_totpage type i.

data: v_temp(3) type c.

Start-of-selection.

do 100 times.

write:/ sy-index.

enddo.

end-of-selection.

v_temp = v_totpage.

do v_totpage times.

read line 1 of page sy-index.

replace '@@@' in sy-lisel with v_temp.

modify line 1 of page sy-index.

enddo.

top-of-page.

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

v_totpage = sy-pagno.

Here is a sample:

  • zlines number of lines in the table

  • sy-srows number of lines in screen

  • sy-cpage current page

  • zpages total number of pages type i

  • temp temporary number type f

describe table itab lines zlines.

temp = zlines / sy-srows.

zpages = trunc( temp ).

temp = frac( temp ).

if temp > 0.

zpages = zpages + 1.

endif.

  • zpages is the number of pages

write: /'Page ',sy-cpage, ' of ', zpages.

Former Member
0 Kudos

Hi Sun,

Try the following code:

The code below shows how to display the total number of pages in a report like "Page 1 / 8."

  • Declare a variable

DATA L_PAGE_COUNT(5) TYPE C.

  • Copy this code to the end of program

  • Page count will be printed on each page here

WRITE SY-PAGNO TO L_PAGE_COUNT LEFT-JUSTIFIED.

DO SY-PAGNO TIMES.

READ LINE 1 OF PAGE SY-INDEX.

REPLACE '-----' WITH L_PAGE_COUNT INTO SY-LISEL.

MODIFY CURRENT LINE.

ENDDO.

TOP-OF-PAGE.

WRITE: /(70) 'Heading' CENTERED, 70 SY-PAGNO,'/ ', '-----'.

Hope this helps you.

Regards,

Chandra Sekhar