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




Serkan AKKAVAK
Computer Engineer
SAP Department Deputy Manager
Contact : serkurumsal@yandex.com