‘Disable’ TOP-OF-PAGE on Last Page in ABAP

0
289

There had been a requirement recently where the user does not want the Header to be displayed on the last page printing in Classical Report. The requirement was pretty unique and here is the sample code based on the condition.

 

Remove Header in Classic Reporting
Remove Header in Classic Reporting

*&———————————————————————*

*& Report  ZTEST_NP_TOP_LAST                                           * 

*&———————————————————————*
*& Example of how to remove the header generated by TOP-OF-PAGE and    *
*&   Move the LIST upwards in the space of the TOP-OF-PAGE             *
*&———————————————————————*

REPORT  ZTEST_NP LINE-COUNT 10(2) NO STANDARD PAGE HEADING.

START-OF-SELECTION.
* Generating the Output
DO 30 TIMES.
  WRITE: / SY-ABCDE.
ENDDO.

* Clearing the last TOP-OF-PAGE
READ LINE 1 OF PAGE SY-PAGNO.
CLEAR SY-LISEL.
MODIFY LINE 1 OF PAGE SY-PAGNO.

* Moving list upword
* Here we are moving only 2 lines, as we have only 2
*   lines in our TOP-OF-PAGE
DATA: L_CNT TYPE I,
      L_LINE TYPE I.
CLEAR: L_CNT, L_LINE.
L_LINE = 2.
DO.
  L_CNT = L_CNT + 1.
  L_LINE = L_LINE + 1.
  READ LINE L_LINE OF PAGE SY-PAGNO.
  IF SY-SUBRC NE 0.
    EXIT.
  ELSE.
    MODIFY LINE L_CNT OF PAGE SY-PAGNO.
    CLEAR SY-LISEL.
    MODIFY LINE L_LINE OF PAGE SY-PAGNO.
  ENDIF.
ENDDO.

* Top of page
TOP-OF-PAGE.
  WRITE: / ‘Heading from TOP OF PAGE Line 1’.
  WRITE: / ‘Line 2’.

LEAVE A REPLY