Dear Anshika,
Try using EVENTS.
"Reading Top-of-page and End-of-page
Data : it_event type slis_alv_event.
Call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = IT_EVENT
- EXCEPTIONS
- LIST_TYPE_WRONG = 1
- OTHERS = 2
READ TABLE IT_EVENT INTO WA_EVENT WITH KEY NAME = 'END_OF_PAGE'.
<b> WA_EVENT-FORM = 'END_OF_PAGE'.
"Similarly you can even read top_of_page
append wa_event to it_event.
clear wa_event.
Form END_OF_PAGE.
***Write your logic
endform.
FORM DISP_ALV .
IF GT_FINAL[] IS NOT INITIAL.
SORT GT_FINAL BY EBELN EBELP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE '
* I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FCAT
I_SAVE = 'A'
IT_EVENTS = IT_EVENT
TABLES
| T_OUTTAB = GT_FINAL |
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
ELSE.
MESSAGE TEXT-002 TYPE 'E'.
ENDIF.
ENDFORM.
Hope this helps.
Regards,
Mounika