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: 

top of page

Former Member
0 Kudos

Dear Friends,

Iam trying to print sy-pageno / total no of pages in top of page . iam doing the calculation part like this.

DATA:a TYPE i,

b TYPE i,

check.

a = sy-linct - 14.

b = sy-dbcnt / a.

c = TRUNC( b ).

check = sy-dbcnt MOD a.

IF check <> '0'.

c = c + 1.

ENDIF.

WRITE: sy-pagno, 'OF', c.

but the problem is iam not able to get value of 'C'(total number of pages),is not getting triggered.can any help me out of this

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi gopi,

Check this code

ABAP Report Page Number

The code below shows how to display the total number of pages in a report like "Page 1 of 8." However, it doesn't work if you execute the program as a background jobs.

  • 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,'of ', '-----'.

Regards,

Kumar.

6 REPLIES 6

Former Member
0 Kudos

you havent declared variable C.

plz check it.

Else its working fine.

Regards,

Vimal

Former Member
0 Kudos

Hi,

Why you r doing both try like below

a = sy-linct - 14.

b = sy-dbcnt / a.

c = TRUNC( b ).

OR

a = sy-linct - 14.

do.

check = sy-dbcnt MOD a.

IF check <> '0'.

c = c + 1.

else.

exit.

ENDIF.

enddo.

Satya.

Former Member
0 Kudos

Hi gopi,

please consider letting SAP to do that automatically. It's much easier! Example:


TOP-OF-PAGE.
  bhdgd-line1 = sy-title.
  bhdgd-line2 = space.
  bhdgd-lines = sy-linsz.
  bhdgd-uname = sy-uname.
  bhdgd-repid = sy-cprog.

  PERFORM batch-heading(rsbtchh0).

  ULINE.

I hope this helps. Best regards,

Alvaro

Former Member
0 Kudos

hi gopi,

Check this code

ABAP Report Page Number

The code below shows how to display the total number of pages in a report like "Page 1 of 8." However, it doesn't work if you execute the program as a background jobs.

  • 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,'of ', '-----'.

Regards,

Kumar.

Former Member
0 Kudos

Hi,

The code below shows how to display the total number of pages in a report like "Page 1 of 8." However, it doesn't work if you execute the program as a background jobs.

  • 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,'of ', '-----'.

Regards

Sudheer

varma_narayana
Active Contributor
0 Kudos

Hi Gopi..

This is the code to Print the Page No as u need...

test this below code. You will get the clear idea.

REPORT YJAM_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.

<b>REWARD IF HELPFUL</b>