SAP ABAP Programming, Functional and Basis Components Books


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

Back to Previous

Return to SAP Hints and Tips on Configuration and ABAP/4 Programming