Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Author: Jatra Riwayanto
Submitted: 02.05.2007

Related Links:

Description:
Yesterday I found question in ABAP Forum, asking about how to create Page of in report. Sridhar got problem how to create page of in reporting like me when I was new in Abap. This simple code will create Page X of XX in header report. I hope this will help overyone who new in Abap.

This code will display report without page of.

REPORT  Z_PAGEOF NO STANDARD PAGE HEADING
                 LINE-COUNT 65(2).

*-----------------------------------------------------------------------
* T.A.B.L.E.
*-----------------------------------------------------------------------
TABLES: PA0001.

*-----------------------------------------------------------------------
* D.A.T.A.
*-----------------------------------------------------------------------
DATA: PAGES(5) TYPE C.

*-----------------------------------------------------------------------
* T.O.P.  .O.F.  .P.A.G.E.
*-----------------------------------------------------------------------
TOP-OF-PAGE.
  SKIP.
  WRITE: /3 'Employee List Report' LEFT-JUSTIFIED, 85 'Page: ',  SY-PAGNO.
  ULINE.
  WRITE: /(20) 'Personal Number' CENTERED, (40) 'Name' LEFT-JUSTIFIED.
  ULINE.

*-----------------------------------------------------------------------
* E.N.D.  .O.F.  .P.A.G.E.
*-----------------------------------------------------------------------
END-OF-PAGE.
  ULINE.

*-----------------------------------------------------------------------
* M.A.I.N.  .P.R.O.G.R.A.M.
*-----------------------------------------------------------------------
START-OF-SELECTION.
*   Report output
    SELECT *
    FROM PA0001.
      WRITE: /(20) PA0001-PERNR CENTERED, (40) PA0001-ENAME LEFT-JUSTIFIED.
    ENDSELECT.

Lets create simple modification that will display Page X of XX.
Replace code in TOP-OF-PAGE:

WRITE: /3 'Employee List Report' LEFT-JUSTIFIED, 85 'Page: ',  SY-PAGNO.

with this code:

WRITE: /3 'Employee List Report' LEFT-JUSTIFIED, 85 'Page: ', SY-PAGNO,'of ', 'PAGEOF'.

Now we need replace 'PAGEOF' with total pages.
Add this code at START-OF-SELECTION below SELECt * ENDSELECT statement.

*   Print Page Number on each page
    WRITE SY-PAGNO TO PAGES LEFT-JUSTIFIED.
    DO SY-PAGNO TIMES.
        READ LINE 2 OF PAGE SY-INDEX.
        REPLACE 'PAGEOF' WITH PAGES INTO SY-LISEL.
        MODIFY CURRENT LINE.
    ENDDO.