How to detect a selected row in ALV GRID

Hi,
Can anyone tell me how to detect and catch an event when a row is selected in an ALV GRID?
I would like to catch such event when the end user presses Ctrl + Shif + Space bar.
Thank you and best regards.
Hassane.

Hi,
Use this wiki link, to have a checkbox with all the records in ALV Grid and to process those selected records at a user command, as per the requirement.
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/alv%252bgrid%252bdisplay%252bwith%252bcheckbox%252bto%252bprocess%252bselected%252brecords%252bat%252bruntime
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir

Similar Messages

  • HOW CAN I HAVE THE NUMBER OF SELECTED ROWS IN ALV GRID?

    HI.
    HOW CAN I HAVE THE NUMBER OF SELECTED ROWS IN ALV GRID????
    GABRY =)

    You need to use
    data : grid1  type ref to cl_gui_alv_grid.
      call method grid1->get_selected_rows
        importing
          et_index_rows = i_sel_alvrows[].

  • How to find the selected item in alv grid or table control

    can any one tell me please
    how to find the selected item in alv grid or table control

    In table control, If you goto screen painter and goto table control properties ( f2 ), there is one check-box w/selColumn check that and give column name. Then add that column to your internal table.
    IN PAI
      LOOP AT it_tkhdr.
        FIELD it_tkhdr-sel_row
          MODULE tab_tkhdr_mark ON REQUEST.
      ENDLOOP.
    MODULE tab_tkhdr_mark INPUT.
      MODIFY it_tkhdr INDEX tc_tkhdr-current_line.
    ENDMODULE.                 " tab_tkhdr_mark  INPUT
    here it_TKHDR is internal table sel_row is field for selection
    After that, you can loop at it_tkhdr where sel_row is 'X' to get selected rows.
    regards,
    Gagan

  • How to identify the modified rows in ALV grid in OO

    Hello All,
    I have strange problem and i don't know how to solve it?
    I have ALV grid and in that ALV grid i have two buttons 'CONT' and 'ALLOC', when the user press 'ALLOC' button i will give a popup to make the user to enter some value.
    After entering the value i will do some calicualtions and i will distribute the amount in the fields of ALV grid and i should update the ALVGRID.
    Normally we can use CALL METHOD ME->REFRESH_TABLE_DISPLAY.( I have already checked by using this method and it worked fine)
    Here is the way my program look like
    ALVTREE1
    ALVTREE2
                 |----
    ALVGRID
    The problem is when i press the other button CONT i am unable to know what values exist in ALVGRID.
    How can i find these distributed amount in ALV?
    I hope i am clear while explaining problem.
    Here is  the required code:
      method handle_user_command.
        data: lt_fields       type table of sval,
              ls_field        type sval,
              ls_fieldcatalog type lvc_s_fcat,
              ls_merkpl       type zvhf_merkpl,
              lv_month(2)     type n ,
              lv_year(4)      type n ,
              lv_spmon        type zvhf_allocation-spmon,
              lv_value        type p.
        field-symbols: <fs> type any,
                       <ls_merkpl> type zvhf_merkpl.
        case  e_ucomm.
          when 'CNT'.
            call method gcl_gui_alv_grid->check_changed_data.
            call method dailogbox_container->set_visible
              exporting
                visible = space.
            call method gcl_gui_alv_tree2->frontend_update.
            call method gcl_gui_alv_tree2->update_calculations.
            clear: gt_merkpl.
          when 'ALCT'.
    Popup to get the values enterd by the user
            ls_field-tabname   = 'DD02V'.
            ls_field-fieldname = 'DDTEXT'.
            append ls_field to lt_fields.
            call function 'POPUP_GET_VALUES'
              exporting
                popup_title     = 'Enter value'
                start_column    = '1'
                start_row       = '1'
              tables
                fields          = lt_fields
              exceptions
                error_in_fields = 1
                others          = 2.
            if sy-subrc <> 0.
              message id sy-msgid type sy-msgty number sy-msgno
                      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
            elseif sy-subrc = 0.
              read table lt_fields into ls_field index 1.
              if sy-subrc = 0.
                gv_value = ls_field-value.
    Read the table zvhf_allocation with nodekey  in order to get percentages
                select * from zvhf_allocation into table gt_allocation
                                   where dvkbur = gs_node_info-nodename.
    Read gt_merkpl in order to get existing line in ALV grid
                loop at  gt_merkpl into ls_merkpl.
    *Read FCAT inorder to find the field and move proprtinate value
                  loop at gt_fieldcatlog3 into ls_fieldcatalog.
    *Split is required to match ZVHF_ALLOCATION-SPMON  with screen text and to proprtinate the value
                    split ls_fieldcatalog-scrtext_l at '.' into
                          lv_month lv_year.
                    concatenate lv_year lv_month into lv_spmon.
    Check whether an entry exist or not in ZVHF_allocation
                    read table gt_allocation into gs_allocation
                                              with key spmon = lv_spmon binary search.
    *If an entry exist proprtinate the value as enterd in table
                    if sy-subrc = 0.
                      lv_value  = gv_value * gs_allocation-prozent.
                      lv_value = lv_value / 100.
                      perform assign_value using     ls_fieldcatalog-fieldname lv_value
                                           changing  ls_merkpl.
                      modify gt_merkpl from ls_merkpl.
                    endif.
                  endloop.
                 CALL METHOD gcl_gui_alv_grid->frontend_update.
                  call method gcl_gui_alv_grid->refresh_table_display
                    exceptions
                      finished = 1
                      others   = 2.
                  if sy-subrc <> 0.
                    message id sy-msgid type sy-msgty number sy-msgno
                               with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
                  endif.
                endloop.
              endif.
            endif.
        endcase.
      endmethod.                    "handle_user_command
    If you have any further questions please let me know.
    Regards,
    Lisa

    Hello Vijay,
    Thanks for you reply,
    The event data_changed is not working because i called method refresh_table_display. So the event changed will not be raised after i press button CONT
    If i didn't call this method then i can see the value enterd by the user in ALV grid.
    So, do you have an more ideas.
    Regards,
    Lisa

  • Displaying the selected rows in ALV Grid output

    Hi Experts,
    I am developing one interactive ALV Grid report where user can process the selected records/rows from the ALV Grid output.
    for displaying the ALV Grid, I have used the class CL_GUI_ALV_GRID class. I am working on ECC 6.0 system.
    when I select any records/rows from output and then press any Application Toolbar button, PAI and then PBO modules of the screen gets executed as per the normal flow.
    however After PBO, when same ALV output comes, all the selected/highlighted rows appear as unselected, that means I want to retain the ALV
    rows selection during the round trip.
    please advise.
    Regards,
    Jagesh

    Hi,
    Feiyun Wu is correct.
    Get_selected_rows and set_selected_rows are the methods to be used .
    Some code:
    Note the sequence of code:
    FORM set_gui_alv_grid_1 .
      DATA: wa_layout TYPE lvc_s_layo ,
            wa_print TYPE lvc_s_prnt .
      DATA: it_sort TYPE lvc_t_sort ,
            wa_sort TYPE LINE OF lvc_t_sort .
      DATA: it_fieldcatalog TYPE lvc_t_fcat.
      IF gui_custom_container_1 IS INITIAL .
        CREATE OBJECT gui_custom_container_1
          EXPORTING
            container_name = 'GUI_CUSTOM_CONTAINER_1'
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6 .
        IF sy-subrc <> 0.
        ENDIF.
        PERFORM get_field_catalog
          USING gc_log_group_1
          CHANGING it_fieldcatalog  .
        CREATE OBJECT gui_alv_grid_1
          EXPORTING i_parent = gui_custom_container_1.
        CREATE OBJECT ob_event_receiver_1
          EXPORTING log_group = gc_log_group_1 .
    * registers the event handlers
        SET HANDLER ob_event_receiver_1->handle_toolbar      FOR gui_alv_grid_1 .
        SET HANDLER ob_event_receiver_1->handle_user_command FOR gui_alv_grid_1 .
        SET HANDLER ob_event_receiver_1->print_top_of_page   FOR gui_alv_grid_1 .
        SET HANDLER ob_event_receiver_1->hotspot_click       FOR gui_alv_grid_1 .
        wa_layout-cwidth_opt = abap_true .
    *   wa_layout-excp_fname = gc_excp_fname .
    *   wa_layout-ctab_fname = gc_ctab_fname.
    *   wa_layout-excp_led   = abap_true .
        CALL METHOD gui_alv_grid_1->set_table_for_first_display
          EXPORTING
            is_layout       = wa_layout
            is_print        = wa_print
            i_save          = 'A'
            is_variant      = gs_disvariant_1
          CHANGING
            it_sort         = it_sort
            it_fieldcatalog = it_fieldcatalog
            it_outtab       = it_alv_grid_1.
      ELSE .
        CALL METHOD gui_alv_grid_1->refresh_table_display.
    * Restore selections
        CALL METHOD gui_alv_grid_1->set_selected_rows
          EXPORTING
            it_index_rows = ob_event_receiver_1->it_rows.
    * Restore position
        CALL METHOD gui_alv_grid_1->set_scroll_info_via_id
          EXPORTING
            is_col_info = ob_event_receiver_1->wa_col
            is_row_no   = ob_event_receiver_1->wa_roid.
      ENDIF.
    ENDFORM .                    "set_gui_alv_grid_1
    Regards.

  • Getting selected rows in ALV grid output

    Hi All,
    As per my requirement, in the ALV output i have 3 push buttons (Display, Edit and Print).
    Using the below code, I am trying to get the selected rows from the output.
        CALL METHOD ob_grid->check_changed_data
          CHANGING
            c_refresh = w_x.
        CALL METHOD ob_grid->get_selected_rows
          IMPORTING
            et_index_rows = is_rows.
    When I execute the code wid Display/Edit push buttons it is working fine as long as Print button is not used.
    If I use the Print button and then try to select any other push button, I am not getting the entries in is_rows internal table.
    Kindly help me.
    Thanks in Advance.

    Would your user actually select a row if they wanted simply to print?   I don't see that you're checking to see if the user actually selected a row ( after et_index_rows = is_rows, need to be sure is_rows is not initial (zero)).    Debug should show you exactly what is happening in the situation you described.

  • Problem in selecting rows in ALV Grid

    Hi All,
    I am doing a ALV Grid program using Classes. when i select 2 rows from that grid and executes,
    it going next screen. Again when  i am using back button and selecting same rows or different rows from teh same Grid and executing it is not retrieving any rows. In dedugger it is showing that the there is no selection of rows.
    Please suggest me the solution.
    Thanks in advance,
    Regards,
    Balaji.

    Hi chaitanya,
    I am not clearing any code.
    please find the code...
    CALL METHOD g_grid1->get_selected_rows
            IMPORTING
              et_index_rows = w_lvc_t_row_1.
          IF w_lvc_t_row_1 IS INITIAL.
            MESSAGE e004(zmsg).
          ELSE.
            CLEAR it_memis1-signal.
            REFRESH po_memis1.
            LOOP AT w_lvc_t_row_1 INTO w_lvc_s_row_1.
              READ TABLE it_memis1 INTO po_memis1 INDEX w_lvc_s_row_1-index.
              SELECT SINGLE name INTO v_nam FROM icon WHERE id = po_memis1-signal.
              IF v_nam = 'ICON_LED_GREEN' OR v_nam = 'ICON_LED_YELLOW'.
                APPEND po_memis1.
                CLEAR po_memis1-signal.
              ELSE.
                MESSAGE 'This item Cannot be processed due to errors' TYPE 'E'.
              ENDIF.
            ENDLOOP.
          ENDIF.
    regards,
    Balaji.

  • Selecting rows in ALV Grid using Classes

    I am displaying the output in ALV grid format.
    Now i am using cl_gui_alv_grid->Get_selected_ROWS to get the row index selected by User and on clicking a button it will take us to another screen which will hold the values of the selected row.
    Problem Faced: But when we again go back to the first screen and select another row  or same rows and click this button the selected rows index remains initial, that value is not getting captured.
    I cleared the parameters and refershed grid also.
    But the problem is not yet solved.
    Please Give me the solution.
    Regards,
    Balaji.

    Hi Lavanya,
    I did debugging also.
    First time Get_Selected_rows is working fine.
    But Second time it is failed.

  • How to get column value of a selected row of ALV

    Hello ,
    I have application POWL POWL_UI_COMP uses  another component  POWL_TABLE_COMP.
    This POWL_TABLE_COMP uses SALV_WD_TABLE.
    I want to select value of ORDER id and it need to be passed whenever user selects a display order button(Which is self defined function generated in POWL_TABLE_COMP) . I am calling a display order on action of this display button(http://nap60.nalco.one.net:8042/sap/bc/webdynpro/sap/mt_order_app?IV_ACTIVITYTYPE=A&IV_EQUIPMENT=aaaa&IV_ORDERID=90001511&IV_ORDERTYPE=STD&IV_QMNUM=00&IV_TPLNR=00)
    ORDERID is one column value of selected row of ALV table.
    So please can you suggest , how to read ORDERID and pass it to the self defined function..
    thanks in advance,
    Sharada

    Anoop,
    I have plcaed this code in event handler of  on_lead_select.
    Its giving error  the element doesnt exist. 
    static_attributes should give me row data but it's giving short dump saying
    Pl can you suggest.
    data:   set_of_element type WDR_CONTEXT_ELEMENT_SET,
            element1 type ref to IF_WD_CONTEXT_ELEMENT,
            result type POWL_CRESULT_STY,
            table_helper type ref to CL_POWL_TABLE_HELPER,
          context_node type ref to IF_WD_CONTEXT_NODE,
           lt_selected_elements TYPE wdr_context_element_set,
           static_attributes type ref to data.
      table_helper = wd_comp_controller->mr_table_helper.
      context_node = table_helper->get_data_node( ).
      context_node = wd_comp_controller->mr_table_helper->get_data_node( ).
      context_node->get_static_attributes( exporting index = r_param->index
                                          importing static_attributes = static_attributes ).
    thanks,
    Sharada

  • How to Edit selected row in ALV

    Hi Experts,
                    I new to webdynpro ABAP. How to Edit the entire selected row in ALV. Please suggest?
    Thanks in advance.

    Hi,
    I guess you have created the node as dynamic and also set this to the ALV..
    1.  Have you created READ_ONLY attribute of type wdy_boolean inside the node to which the ALV is bound..If not create it first and set the default value for this readonly as abap_true...ie X.
    2.  Got the contents in the internal table.
    bind the table to the node..
    3.Instantiate the ALV.
    4. Now get teh column refrences of this ALV using the cl_salv_wd_config_table..and for columns
    use the cell editor type as cl_salv_wd_uie_input_field...
    loop through the column references and for all refrences create an object of type Input field and inside this class
    use the method set_read_only_field_name ( 'READ_ONLY' ).
    For the table settings if_salv_wd_table_settings of cl_salv_wd-config_table.. set the read only mode as abap_false..
    5 create the custom button in the ALV using the cl_salv_wd_fe_button..
    6 In this go for the events ON_FUCNTION and inside this method..do the coding
    7 .Initially the table will  be set to non editable..
    In the button handler....
    Get the refernece of this node to which the ALV is bound.....
    lr_node = wd_context->get_child_node( 'VBAK' ).  "dynamic node name
    lv_index  = lr_node->get_lead_selection_index ( ).
    loop at it_table into ls_table.
    if sy-tabix eq lv_index.
    ls_table-read_only = abap_false.  "editable
    else.
    ls_table-read_only = abap_true. "non editable
    endif.
    modify table
    endloop.
    lr_node->bind_table( lt_table ).
    If you have any doutbs just refer the previous thread posted on the same..
    You can follow the above steps to acheive thjs..
    Regards,
    Lekha.
    Edited by: Lekha on Dec 17, 2009 6:10 PM

  • How to delete a particular row in ALV table

    Hi,
    How to delete a particular row in ALV table based on some condition(by checking value for one of the columns in a row)
    Thanks
    Bala Duvvuri

    Hello Bala,
    Can you please be a bit more clear as to how you intend to delete the rows from your ALV? By the way deleting rows from an ALV is no different from deleting rows from a normal table. Suppose you have enabled selection property in ALV & then select multiple rows and click up on a button to delete the rows then below would be the coding: (Also keep in mind that you would have to maintain the Selection property of the context node that you are binding to your ALV to 0..n)
    data : lr_table_settings  TYPE REF TO if_salv_wd_table_settings,
                 lr_config          TYPE REF TO cl_salv_wd_config_table.
      lr_table_settings  ?= lr_config.
    ** Setting the ALV selection to multiple selection with no lead selection
      lr_table_settings->set_selection_mode( value = cl_wd_table=>e_selection_mode-multi_no_lead ).
    Next delete the selected rows in the action triggered by the button:
    METHOD onactiondelete_rows .
      DATA:  wd_node TYPE REF TO if_wd_context_node,
             lt_node1 TYPE ig_componentcontroller=>elements_node,
             wa_temp  TYPE REF TO if_wd_context_element,
             lt_temp  TYPE wdr_context_element_set,
             row_number TYPE i VALUE 0.
      wd_node = wd_context->get_child_node( name = 'NODE' ).
      CALL METHOD wd_node->get_selected_elements
        RECEIVING
          set = lt_temp.
      LOOP AT lt_temp INTO wa_temp.
        wd_node->remove_element( EXPORTING element = wa_temp ).
      ENDLOOP.
      CALL METHOD wd_node->get_static_attributes_table
        EXPORTING
          from  = 1
          to    = 2147483647
        IMPORTING
          table = lt_node1.
      wd_node->bind_table( new_items = lt_node1 ).
    ENDMETHOD.
    If in case this isn't your requirement please do let me know so that I can try come up with another analysis.
    Regards,
    Uday

  • How to Extract the selected line in alv?

    Hi,
      I am learning ABAP and i have a doubt.It is as follows.
    In interactive reports, by clicking on a ROW we can display the line by using SY_LISEL in AT LINE_SELECTION event .
    Now i want to have a pop up window when we click on a selected row of ALV  report I want that single ROW to be displayed . How can i do this?

    Hi Ravindra,
    I think this is not possible with ALV reports because these use field catalogs unlike Interactive reports. Interactive reports only has the capability of popping up the data in the next list when clicked on row with the help of the events.
    Hope this helps.
    Please reward if useful.
    Thanks,
    Srinivasa

  • How to hide selection column from alv grid

    hi
    i want to hide selection columns form alv grid.. how can i do it.. Is there any fm for that?
    regards
    palak

    Hi,
    the ALV Grid Control allows you to directly hide key columns with NO_OUT (field KEY_SEL is not used).
    Field name:NO_OUT
    Comp. type:LVC_NOOUT
    Dtype(length):Char(1)
    SPACE, 'X'
    If you set this field, you hide the relevant column in the list. Nevertheless, the column is available in the field selection and can be interactively selected by the user as a display field. The ALV displays the contents of hidden fields on the detail screen for a row in the grid control.
    Regards,
    Neenu.
    Edited by: Neenu Jose on Oct 21, 2008 10:46 AM

  • How to delete the selected rows in a JTable on pressing a button?

    How to delete the selected rows in a JTable on pressing a button?

    You are right. I did the same.
    Following is the code where some of them might find it useful in future.
    jTable1.selectAll();
    int[] array = jTable1.getSelectedRows();
    for(int i=array.length-1;i>=0;i--)
    DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
    model.removeRow(i);
    }

  • How to change a color for a row in ALV grid display

    Hi,
       how to change a color for a row in ALV grid display based on a condition.Any sample code plz

    Hello Ramya,
    Did you check in [SCN|How to color a row of  alv grid]
    Thanks!

Maybe you are looking for

  • Creating forms in Acrobat 8 Standard version (ver. 8.3.1)

    I have Adobe Acrobat 8 Standard. My boss wants me to create forms to use on the web (for our intranet). I am told by the IT group that I can create secure forms with fields with the version that I have. I cannot find any info on the web that substant

  • IT0008

    Hi, My client hires a visiting faculty for 6 hrs, his class might be 1 hr per day or 2 hrs per day. If his class is 1 hr per day then he would work for 6 days, if its 2 hrs per day he would work for 3 days. Then his contract ends. 1) How do I create

  • Time machine backup to unsupported drive

    Found this over at Mac Forums seems to work. http://forums.macrumors.com/showpost.php?p=4446263&postcount=126

  • How can I check that all numbers in a serial number are numeric

    I wrote a vi that checks to make sure that a serial number is in the "mmddyy-xxx" format, where xxx can be from 0 to 999. The problem is if I enter something like "012210-A1" it passes. Is there an easy fix to fail anything where xxx is not in the 0

  • Several Lumia 820 Hardware Issues

    Hi, I bought my Lumia 820 3 weeks ago. I've come across a number of hardware issues that i noticed in those three weeks. First, i found the batteries very difficult to remove. I damaged both the battery and the recessed part for the fingers just to i