on 07-09-2013 10:25 AM
Hi All,
I need to insert a code on selecting "Select All' option in "table selection menu" in ALV. But I am not getting any event on which I can write the code as no event is getting triggered. The only place where my debugger stops is the WDDOMODIFYVIEW of the View in which my ALV is there. Is there any work around for it.
Thanks & Regards,
Kumar
Hi Kumar,
I think there is no standard event available for 'Select all' option.
What you can do is, in the WDDOMODIFYVIEW, get all the selected rows using method get_selected_elements( ).
Also get all the rows from the context. then get the no of lines of each tables using describe command.
If both are equal means, all rows has been selected.
Thanks,
Viji.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Vijay,
Thanks for the alternative. I know I can do it from WDDOMODIFYVIEW,but I thought there might be a Standard Event which can help me to perform the task as SAP has given many events for other standard functions too.
Is there any way from which I can get the action name in WDDOMODIFYVIEW,as I have other code also written in the WDDOMODIFYVIEW which I dont want to execute it again and again.
Thanks,
Kumar
Hi Kumar,
As how you have said there is no standard event that gets triggered by the "Select All" option. You can get around this by creating your own custom "Select All" & "Deselect All" buttons and put in your code within the same.
. Remove existing function buttons in ALV toolbar
2. Add new buttons to the ALV toolbar (Select All and Deselect All)
3. Select All button will select rows only displayed in that view and not all. Same for the Deselect All button.
Create new buttons and perform the desired functionality:
Modify the SET_ALV method with the below code -
METHOD set_alv .
DATA:
l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
DATA:
l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table,
l_value TYPE REF TO cl_salv_wd_config_table,
l_form_layout TYPE REF TO cl_salv_form_layout_data_flow.
DATA:
lr_column TYPE REF TO cl_salv_wd_column,
lr_column_header TYPE REF TO cl_salv_wd_column_header.
DATA:
ddic_bind_none TYPE wdy_uie_library_enum_type.
DATA:
lr_table_settings TYPE REF TO if_salv_wd_table_settings,
lr_header TYPE REF TO cl_salv_wd_header.
DATA:
lr_field_settings TYPE REF TO if_salv_wd_field_settings.
DATA:
lr_field TYPE REF TO cl_salv_wd_field,
lr_sort_rule TYPE REF TO cl_salv_wd_sort_rule,
lr_aggr_rule TYPE REF TO cl_salv_wd_aggr_rule,
lr_cbox TYPE REF TO cl_salv_wd_uie_checkbox.
DATA lr_buttonui TYPE REF TO cl_salv_wd_fe_button.
DATA button1 TYPE REF TO cl_salv_wd_function.
DATA button2 TYPE REF TO cl_salv_wd_function.
* Get reference to ALV component usage
l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
l_ref_cmp_usage->create_component( ).
ENDIF.
l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
l_value = l_ref_interfacecontroller->get_model( ).
* Hide View Drop Down list box
l_value->if_salv_wd_std_functions~set_view_list_allowed( abap_false ).
l_value->if_salv_wd_std_functions~set_pdf_allowed( abap_false ).
* Hide standard function buttons
l_value->if_salv_wd_std_functions~set_edit_append_row_allowed( abap_false ).
l_value->if_salv_wd_std_functions~set_edit_insert_row_allowed( abap_false ).
l_value->if_salv_wd_std_functions~set_edit_delete_row_allowed( abap_false ).
l_value->if_salv_wd_std_functions~set_edit_check_available( abap_false ).
* Set the table heading and empty column text
lr_table_settings ?= l_value .
lr_table_settings->set_empty_table_text( `No Results Found` ).
lr_header = lr_table_settings->get_header( ).
lr_header->set_text( `Bookings Summary List` ).
*- Set ALV editable
lr_table_settings->set_read_only( abap_false ).
lr_table_settings->set_row_selectable( abap_false ).
lr_table_settings->set_selection_mode( cl_wd_table=>e_selection_mode-auto ).
lr_table_settings->set_cell_action_event_enabled( abap_false ).
* Change header for the columns & create a checkbox
lr_column = l_value->if_salv_wd_column_settings~get_column( `SELECTED` ).
CREATE OBJECT lr_cbox
EXPORTING
checked_fieldname = `SELECTED`.
lr_column->set_cell_editor( lr_cbox ).
lr_column_header = lr_column->get_header( ).
lr_column_header->set_ddic_binding_field( ddic_bind_none ).
lr_column_header->set_text( ` ` ). "Set Blank header
* Create new select all button
CREATE OBJECT lr_buttonui.
lr_buttonui->set_text( 'Select all' ).
lr_buttonui->set_image_source( 'ICON_SELECT_ALL' ).
button1 = l_value->if_salv_wd_function_settings~create_function( id = 'SELECT' ).
button1->set_editor( lr_buttonui ).
* Create new deselect all button
CREATE OBJECT lr_buttonui.
lr_buttonui->set_text( 'Deselect all' ).
lr_buttonui->set_image_source( 'ICON_DESELECT_ALL' ).
button2 = l_value->if_salv_wd_function_settings~create_function( id = 'DESELECT' ).
button2->set_editor( lr_buttonui ).
lr_column = l_value->if_salv_wd_column_settings~get_column( 'CONNID' ).
lr_column_header = lr_column->get_header( ).
lr_column_header->set_ddic_binding_field( ddic_bind_none ).
lr_column_header->set_text( 'Flight Connection No.' ).
* Hide column Invoice
lr_column = l_value->if_salv_wd_column_settings~get_column( 'INVOICE' ).
lr_column->set_visible( if_wdl_core=>visibility_blank ).
lr_field_settings ?= l_value.
lr_field_settings->set_group_aggr_displayed( abap_true ).
*...Sort Field CONNID
lr_field = lr_field_settings->get_field( 'CONNID' ).
lr_field->if_salv_wd_sort~set_group_aggregation_allowed( abap_true ).
lr_field->if_salv_wd_sort~create_sort_rule( ).
lr_sort_rule = lr_field->if_salv_wd_sort~get_sort_rule( ).
lr_sort_rule->set_sort_order( if_salv_wd_c_sort=>sort_order_ascending ).
lr_sort_rule->set_group_aggregation( abap_true ).
*...Sort Field CUSTOMID
lr_field = lr_field_settings->get_field( 'CUSTOMID' ).
lr_field->if_salv_wd_sort~set_group_aggregation_allowed( abap_true ).
lr_field->if_salv_wd_sort~create_sort_rule( ).
lr_sort_rule = lr_field->if_salv_wd_sort~get_sort_rule( ).
lr_sort_rule->set_sort_order( if_salv_wd_c_sort=>sort_order_ascending ).
lr_sort_rule->set_group_aggregation( abap_true ).
*...Subtotal for Foreign Currency
lr_field = lr_field_settings->get_field( 'FORCURAM' ).
lr_field->if_salv_wd_aggr~create_aggr_rule( ).
lr_aggr_rule = lr_field->if_salv_wd_aggr~get_aggr_rule( ).
lr_aggr_rule->set_aggregation_type( if_salv_wd_c_aggregation=>aggrtype_total ).
*...Subtotal for Local Currency
lr_field = lr_field_settings->get_field( 'LOCCURAM' ).
lr_field->if_salv_wd_aggr~create_aggr_rule( ).
lr_aggr_rule = lr_field->if_salv_wd_aggr~get_aggr_rule( ).
lr_aggr_rule->set_aggregation_type( if_salv_wd_c_aggregation=>aggrtype_total ).
ENDMETHOD.
Now add a Event handler as shown below :
METHOD on_alv_func .
DATA event TYPE string.
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
DATA lo_value TYPE REF TO cl_salv_wd_config_table.
DATA : l_first TYPE i,
l_total TYPE i,
l_temp TYPE i,
l_last TYPE i,
lv_to TYPE i.
DATA lt_elements TYPE wdr_context_element_set.
DATA : lv_proceed TYPE flag,
lv_selected TYPE flag.
DATA lo_element TYPE REF TO if_wd_context_element.
DATA lo_node TYPE REF TO if_wd_context_node.
* Read the context node
lo_node = wd_context->get_child_node( 'SBOOK' ).
* get the current visible row counts in alv
lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
lo_value = lo_interfacecontroller->get_model( ).
CALL METHOD lo_value->if_salv_wd_table_settings~get_first_visible_row
RECEIVING
value = l_first.
CALL METHOD lo_value->if_salv_wd_table_settings~get_visible_row_count
RECEIVING
value = l_total.
* Get the event ID
event = r_param->id.
IF event = 'SELECT'."select all button event
lv_to = l_first + l_total - 1.
lt_elements = lo_node->get_elements( from = l_first
to = lv_to ).
LOOP AT lt_elements INTO lo_element.
lo_element->get_attribute( EXPORTING name = 'SELECTED'
IMPORTING value = lv_selected ).
IF lv_selected = space.
lo_element->set_attribute(
EXPORTING
name = `SELECTED`
value = 'X' ).
ENDIF.
CLEAR lo_element.
ENDLOOP.
ELSEIF event = 'DESELECT'."deselect all button event
lv_to = l_first + l_total.
lt_elements = lo_node->get_elements( from = l_first
to = lv_to ).
LOOP AT lt_elements INTO lo_element.
lo_element->set_attribute(
EXPORTING
name = `SELECTED`
value = space ).
ENDLOOP.
ENDIF.
ENDMETHOD.
Now test the application:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Uday,
I already have that buttons Select All and Deselect All on my ALV that i added using
cl_salv_wd_fe_button. But I also have the functionality of Multiple selection of rows and so "table Menu Selection" is also there. So I want to handle select all button present in "table Menu Selection".
Regards,
Kumar
User | Count |
---|---|
85 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.