Open all | Close all
|
Add Event functionality to ALVgrid report
In order to add event functionality such as 'END_OF_PAGE' to the ALV grid you need to setup the
IT_EVENTS option of the ALV function module. Also depending on which event you are using you
may also need to setup the print parameters by activating the IS_PRINT option. Please note for events
such as end_of_page, end_of_list etc they will not be displayed on screen but only in the printed
output.
Step 1. Add data declaration for events and print parameters
Step 2. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include parameter 'it_events' and 'is_print'
Step 3. Add code to setup events table and print parameters
Step 4. Create event FORM(s), which are executed when event is triggered
|
DATA: gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
|
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
|
perform build_events.
perform build_print_params.
*&------------------------------------------------------------------*
*& Form BUILD_EVENTS
*&------------------------------------------------------------------*
* Build events table
*-------------------------------------------------------------------*
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*&------------------------------------------------------------------*
*& Form BUILD_PRINT_PARAMS
*&------------------------------------------------------------------*
* Setup print parameters
*-------------------------------------------------------------------*
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
|
*&------------------------------------------------------------------*
*& Form END_OF_PAGE
*&------------------------------------------------------------------*
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*&------------------------------------------------------------------*
*& Form END_OF_LIST
*&------------------------------------------------------------------*
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
|
|
|