<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ALV OBJECT : get selected datas in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960141#M394827</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This code will help u to get the selected rows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Refer this code

INCLUDE &amp;lt;icon&amp;gt;.
 
* Predefine a local class for event handling to allow the
* declaration of a reference variable before the class is defined.
CLASS lcl_event_receiver DEFINITION DEFERRED.
CLASS cl_gui_container DEFINITION LOAD.
 
DATA : o_alvgrid          TYPE REF TO cl_gui_alv_grid,
       o_dockingcontainer TYPE REF TO cl_gui_docking_container,
       o_eventreceiver    TYPE REF TO lcl_event_receiver.
CLASS lcl_event_receiver DEFINITION.
 
*   event receiver definitions for ALV actions
  PUBLIC SECTION.
    CLASS-METHODS:
* Status bar
       handle_user_command
        FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING e_ucomm.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_user_command.
* In event handler method for event USER_COMMAND: Query your
*   function codes defined in step 2 and react accordingly.
 
    CASE e_ucomm.
 
      WHEN 'FCODE'.
 
        CALL METHOD o_alvgrid-&amp;gt;get_selected_rows
          IMPORTING
            et_index_rows = i_selected_rows
*            ET_ROW_NO     =
            .
 
        IF i_selected_rows[] IS INITIAL.
          MESSAGE i153 WITH text-009.
          LEAVE LIST-PROCESSING.
        ENDIF.
 
        CLEAR: w_reviewed_mat.
 
*        w_reviewed_mat-reviewed = c_x.
*        w_reviewed_mat-reviewedby = sy-uname.
*        w_reviewed_mat-reviewedon = sy-datum.
 
        LOOP AT i_selected_rows INTO w_selected_rows.
          READ TABLE i_output INTO w_output INDEX w_selected_rows-index.
          IF sy-subrc EQ 0.
            w_reviewed_mat-matnr = w_output-matnr.
          ENDIF.
          APPEND w_reviewed_mat TO i_reviewed_mat.
          CLEAR: w_reviewed_mat-matnr.
        ENDLOOP.
 
*        MODIFY zzcs_mat FROM TABLE i_reviewed_mat.
 
      WHEN OTHERS.
 
    ENDCASE.
  ENDMETHOD.
 
In PBO after creating container 
SET HANDLER o_eventreceiver-&amp;gt;handle_user_command  FOR o_Alvgrid.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This solved ur problem or not?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Judith Jessie Selvi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Feb 2007 09:24:22 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-19T09:24:22Z</dc:date>
    <item>
      <title>ALV OBJECT : get selected datas</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960139#M394825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I built two alv in a same screen of a transaction&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First I want to add a command for each line of the first screen in order to select one or severals lines pushing CTRL.(same with REUSE_ALV_GRID_DISPLAY )&lt;/P&gt;&lt;P&gt;With default settings, the command is not displayed. Do you know how to display it ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.Then I 'd like to get the selected rows of the first ALV. The command to valid the select the rows is out of the first ALV. DO you have a method to do so or an example ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bertrand.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 09:04:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960139#M394825</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T09:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: ALV OBJECT : get selected datas</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960140#M394826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the layout set &lt;/P&gt;&lt;P&gt;DATA:  w_layout  TYPE lvc_s_layo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &amp;lt;b&amp;gt;w_layout-sel_mode   = 'A'.&amp;lt;/b&amp;gt; U will get the buttons for selecting multiple rows.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 09:21:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960140#M394826</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T09:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: ALV OBJECT : get selected datas</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960141#M394827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This code will help u to get the selected rows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Refer this code

INCLUDE &amp;lt;icon&amp;gt;.
 
* Predefine a local class for event handling to allow the
* declaration of a reference variable before the class is defined.
CLASS lcl_event_receiver DEFINITION DEFERRED.
CLASS cl_gui_container DEFINITION LOAD.
 
DATA : o_alvgrid          TYPE REF TO cl_gui_alv_grid,
       o_dockingcontainer TYPE REF TO cl_gui_docking_container,
       o_eventreceiver    TYPE REF TO lcl_event_receiver.
CLASS lcl_event_receiver DEFINITION.
 
*   event receiver definitions for ALV actions
  PUBLIC SECTION.
    CLASS-METHODS:
* Status bar
       handle_user_command
        FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING e_ucomm.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_user_command.
* In event handler method for event USER_COMMAND: Query your
*   function codes defined in step 2 and react accordingly.
 
    CASE e_ucomm.
 
      WHEN 'FCODE'.
 
        CALL METHOD o_alvgrid-&amp;gt;get_selected_rows
          IMPORTING
            et_index_rows = i_selected_rows
*            ET_ROW_NO     =
            .
 
        IF i_selected_rows[] IS INITIAL.
          MESSAGE i153 WITH text-009.
          LEAVE LIST-PROCESSING.
        ENDIF.
 
        CLEAR: w_reviewed_mat.
 
*        w_reviewed_mat-reviewed = c_x.
*        w_reviewed_mat-reviewedby = sy-uname.
*        w_reviewed_mat-reviewedon = sy-datum.
 
        LOOP AT i_selected_rows INTO w_selected_rows.
          READ TABLE i_output INTO w_output INDEX w_selected_rows-index.
          IF sy-subrc EQ 0.
            w_reviewed_mat-matnr = w_output-matnr.
          ENDIF.
          APPEND w_reviewed_mat TO i_reviewed_mat.
          CLEAR: w_reviewed_mat-matnr.
        ENDLOOP.
 
*        MODIFY zzcs_mat FROM TABLE i_reviewed_mat.
 
      WHEN OTHERS.
 
    ENDCASE.
  ENDMETHOD.
 
In PBO after creating container 
SET HANDLER o_eventreceiver-&amp;gt;handle_user_command  FOR o_Alvgrid.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This solved ur problem or not?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Judith Jessie Selvi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 09:24:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960141#M394827</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T09:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: ALV OBJECT : get selected datas</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960142#M394828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Bertrand,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using OOPS ALV,to select one or more rows,you have to pass a layout structure in the method SET_TABLE_FOR_FIRST_DISPLAY.For ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;DATA:gs_layout TYPE lvc_s_layo.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;gs_layout-sel_mode = 'A'.&lt;/P&gt;&lt;P&gt;&amp;lt;/b&amp;gt;CALL METHOD gv_alv-&amp;gt;set_table_for_first_display&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;is_layout = gs_layout&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can append A,B,C,D based on your requirements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;'A'&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Column and row selection&lt;/P&gt;&lt;P&gt;&amp;#149; Multiple columns&lt;/P&gt;&lt;P&gt;&amp;#149; Multiple rows&lt;/P&gt;&lt;P&gt;The user selects the rows through pushbuttons at the left border of the grid control.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;'B'&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Simple selection, list box&lt;/P&gt;&lt;P&gt;&amp;#149; Multiple columns&lt;/P&gt;&lt;P&gt;&amp;#149; Multiple rows&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;'C'&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Multiple selection, list box&lt;/P&gt;&lt;P&gt;&amp;#149; Multiple columns&lt;/P&gt;&lt;P&gt;&amp;#149; Multiple rows&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;'D'&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Cell selection&lt;/P&gt;&lt;P&gt;&amp;#149; Multiple columns&lt;/P&gt;&lt;P&gt;&amp;#149; Multiple rows&lt;/P&gt;&lt;P&gt;&amp;#149; Any cells&lt;/P&gt;&lt;P&gt;The user selects the rows through pushbuttons at the left border of the grid control.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To get selected rows,you can use the method GET_SELECTED_ROWS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;CALL METHOD gv_alv-&amp;gt;get_selected_rows&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;ET_INDEX_ROWS =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;et_row_no = lt_selected_rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE gt_it_schd_lines INTO&lt;/P&gt;&lt;P&gt;gs_wa_schd_lines INDEX &amp;lt;b&amp;gt;ls_selected_row-row_id&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Beejal&lt;/P&gt;&lt;P&gt;**Reward if this helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 09:27:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960142#M394828</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T09:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: ALV OBJECT : get selected datas</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960143#M394829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a remaining problem.&lt;/P&gt;&lt;P&gt;The command to valid selection is not inside the alv grid. So the method doesn't catch the selected data of my grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know how to resolve this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bertrand.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 10:08:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960143#M394829</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T10:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: ALV OBJECT : get selected datas</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960144#M394830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Bertrand,&lt;/P&gt;&lt;P&gt;You can get the selected row-index using the method GET_SELECTED_ROWS.Then you can loop through the internal table used in the alv to fetch the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE &amp;lt;b&amp;gt;gt_it_schd_lines&amp;lt;/b&amp;gt; INTO&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;gs_wa_schd_lines&amp;lt;/b&amp;gt; INDEX &amp;lt;b&amp;gt;ls_selected_row-row_id&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here,&amp;lt;b&amp;gt;gt_it_schd_lines&amp;lt;/b&amp;gt; is my internal table and based on the selected row-index (&amp;lt;b&amp;gt;ls_selected_row-row_id&amp;lt;/b&amp;gt;),I can read my internal table to a work area &amp;lt;b&amp;gt;gs_wa_schd_lines&amp;lt;/b&amp;gt;.Now the work area &amp;lt;b&amp;gt;gs_wa_schd_lines&amp;lt;/b&amp;gt; will have the selected data of your grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to validate the data in the selected row,you can bring it to the work area as shown above (&amp;lt;b&amp;gt;gs_wa_schd_lines&amp;lt;/b&amp;gt;) and then validate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Beejal&lt;/P&gt;&lt;P&gt;**Reward if this helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 10:18:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960144#M394830</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T10:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: ALV OBJECT : get selected datas</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960145#M394831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I was trying to say is that GET_SELECTED_ROWS doesn't catch the selected rows besause my command is not in the ALV. It is one of the transaction screen command (in the middle of the screen).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bertrand&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 10:23:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960145#M394831</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T10:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: ALV OBJECT : get selected datas</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960146#M394832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if the command is not in ALV u cant capture the selected rows.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 10:27:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960146#M394832</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T10:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: ALV OBJECT : get selected datas</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960147#M394833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the button(command) is not inside the container then it will not work because what ever operation u are doing (ie, selecting of multiple rows )is specific to the container itself.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 10:40:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-object-get-selected-datas/m-p/1960147#M394833</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T10:40:22Z</dc:date>
    </item>
  </channel>
</rss>

