* _______ _______ _______ _______ _______ _______ ______ _______ _______ ______ _______ * | _ | _ | _ | | | _ | || _ | _ | _ | | _ | * | |_| | |_| | |_| | _ | | |_| | _ | |_| | |_| | | || | |_| | * | | | | |_| | | | | | | | | |_||_| | * | | _ || | ___| _| | |_| | | _ || __ | | * | _ | |_| | _ | | | |_| _ | | _ | |_| | | | | _ | * |__| |__|_______|__| |__|___| |_______|__| |__|______||__| |__|_______|___| |_|__| |__| * www.abapcadabra.com report ZDEMO_ALV_4_INTERACTIVE. include ZABAPCADABRA_EASY_ALV. types: begin of lty_mara, matnr type mara-matnr, something type char20, end of lty_mara. class lcl_event_manager definition deferred. data: gt_data type table of lty_mara, gw_data type lty_mara, go_alv type ref to lcl_easy_alv, go_salv type ref to cl_salv_table, go_event_man type ref to lcl_event_manager. *------------------------------------------------------------- * CLASS lcl_event_manager DEFINITION *------------------------------------------------------------- * An example subclass for processing events *------------------------------------------------------------- class lcl_event_manager definition. public section. methods: constructor importing r_object type ref to cl_salv_table, on_user_command for event added_function of cl_salv_events importing e_salv_function, on_double_click for event double_click of cl_salv_events_table importing row column, on_link_click for event link_click of cl_salv_events_table importing row column. private section. data: go_salv type ref to cl_salv_table. endclass. "lcl_event_manager DEFINITION *------------------------------------------------------------- * CLASS lcl_event_manager IMPLEMENTATION *------------------------------------------------------------- * Allow response for double clicks and user commands (menu * actions) *------------------------------------------------------------- class lcl_event_manager implementation. method constructor. data: lo_events type ref to cl_salv_events_table. go_salv = r_object. lo_events = go_salv->get_event( ). set handler on_user_command for lo_events. set handler on_double_click for lo_events. set handler on_link_click for lo_events. endmethod. method on_user_command. data: lt_rows type salv_t_row, lv_row type int4, lv_footer_text type string, lo_selections type ref to cl_salv_selections. case e_salv_function. when 'DO_IT'. * Get the selected entries lo_selections = go_salv->get_selections( ). lt_rows = lo_selections->get_selected_rows( ). loop at lt_rows into lv_row. read table gt_data index lv_row into gw_data. gw_data-something = '*processed*'. modify gt_data index lv_row from gw_data. endloop. describe table lt_rows lines lv_footer_text. concatenate lv_footer_text 'rows processed' into lv_footer_text separated by space. go_alv->set_footer_line( col1 = lv_footer_text reset_footer = abap_true ). go_alv->display( refresh = abap_true ). endcase. endmethod. "on_user_command method on_double_click. read table gt_data index row into gw_data. gw_data-something = '*doubleclicked*'. modify gt_data index row from gw_data. go_alv->set_footer_line( col1 = 'Double click' reset_footer = abap_true ). go_alv->display( refresh = abap_true ). endmethod. "on_double_click method on_link_click. go_alv->set_footer_line( col1 = 'Hotspot click' reset_footer = abap_true ). go_alv->display( refresh = abap_true ). endmethod. "on_link_click endclass. start-of-selection. select * from mara into corresponding fields of table gt_data up to 30 rows. create object go_alv. go_alv->set_alv_from_template( exporting menu_report = 'SAPLSLVC_FULLSCREEN' menu_pfstatus = 'STANDARD_FULLSCREEN' changing content = gt_data salv_table = go_salv ). go_alv->set_selection_mode( 2 ). go_alv->set_sort( fieldname = 'MATNR' ). "2nd sort field go_alv->set_field( fieldname = 'MATNR' is_hotspot = abap_true is_key = abap_false ). go_alv->set_footer_line( '30 lines from material table' ). create object go_event_man exporting r_object = go_salv. go_alv->display( ).