How to write pageno of totalpages in report

Below are two examples of  how to write Page xx of  xx  in the top of a report

I have testet example 1 and it works. I have note testet example 2


Example 1

I have found this example at The SAP Fan Club 

Click here to go directly to the topic



REPORT Y_PAGE_NUMBER_EXERCISE NO STANDARD PAGE HEADING LINE-SIZE 80
LINE-COUNT 55.

TABLES: VBAP.

SELECT-OPTIONS: ORDER FOR VBAP-VBELN.

DATA: IVBAP TYPE STANDARD TABLE OF VBAP WITH HEADER LINE,
            TAB_ENTRIES TYPE I,
            TOTAL_PAGES TYPE P DECIMALS 3,
            TOTAL_NUMBER_OF_PAGES TYPE P DECIMALS 0,
            HEADER_LINE_COUNT TYPE I VALUE 3.

SELECT * FROM VBAP INTO TABLE IVBAP WHERE VBELN IN ORDER.

DESCRIBE TABLE IVBAP LINES TAB_ENTRIES.

TOTAL_PAGES = ( TAB_ENTRIES / SY-LINCT ).

TOTAL_PAGES = ( ( ( TOTAL_PAGES * HEADER_LINE_COUNT )
+ TAB_ENTRIES ) / SY-LINCT ).
TOTAL_NUMBER_OF_PAGES = CEIL( TOTAL_PAGES ).

LOOP AT IVBAP.
    WRITE:/ IVBAP-VBELN,
IVBAP-POSNR.

ENDLOOP.

TOP-OF-PAGE.

    WRITE:/ 'LIST OF SALES ORDERS',
    45 'Page',
    SY-PAGNO,
    'of' NO-GAP,
    TOTAL_NUMBER_OF_PAGES.
ULINE.
SKIP.





Example 2



REPORT ZLTEST3 NO STANDARD PAGE HEADING LINE-COUNT 65LINE-SIZE 80.

DATA: NUM_PAGES_C(10) TYPE C.
PERFORM WRITE.
PERFORM GET_TOTAL_PAGENO.
TOP-OF-PAGE.

WRITE:/(SY-LINCT) 'TEST - TEST' CENTERED.
WRITE: / SY-DATUM, 60 SY-PAGNO,'of', '*****'.
SKIP.
*&---------------------------------------------------------------------*
*& Form WRITE
*&---------------------------------------------------------------------*
FORM WRITE.
DO 200 TIMES.
WRITE:/ 'TEST', SY-LINNO.
ENDDO.
ENDFORM. " WRITE
*&---------------------------------------------------------------------*
*& Form GET_TOTAL_PAGENO
*&---------------------------------------------------------------------*
FORM GET_TOTAL_PAGENO.
WRITE SY-PAGNO TO NUM_PAGES_C LEFT-JUSTIFIED.
DO SY-PAGNO TIMES.
READ LINE 2 OF PAGE SY-INDEX.
REPLACE '*****' WITH NUM_PAGES_C INTO SY-LISEL.
MODIFY LINE 2 OF PAGE SY-INDEX.
ENDDO.
ENDFORM. " GET_TOTAL_PAGENO


 

Converted from CHM to HTML with chm2web Standard 2.7 (unicode)