‎2007 Feb 19 9:04 AM
Hello,
I built two alv in a same screen of a transaction
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 )
With default settings, the command is not displayed. Do you know how to display it ?
.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 ?
Thanks for help,
Bertrand.
‎2007 Feb 19 9:27 AM
Hello Bertrand,
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:
<b>
DATA:gs_layout TYPE lvc_s_layo.</b>
<b>gs_layout-sel_mode = 'A'.
</b>CALL METHOD gv_alv->set_table_for_first_display
EXPORTING
<b>is_layout = gs_layout</b>
You can append A,B,C,D based on your requirements.
<b>'A'</b>
Column and row selection
Multiple columns
Multiple rows
The user selects the rows through pushbuttons at the left border of the grid control.
<b>'B'</b>
Simple selection, list box
Multiple columns
Multiple rows
<b>'C'</b>
Multiple selection, list box
Multiple columns
Multiple rows
<b>'D'</b>
Cell selection
Multiple columns
Multiple rows
Any cells
The user selects the rows through pushbuttons at the left border of the grid control.
To get selected rows,you can use the method GET_SELECTED_ROWS.
<b>CALL METHOD gv_alv->get_selected_rows</b>
IMPORTING
ET_INDEX_ROWS =
et_row_no = lt_selected_rows.
<b>READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .</b>
READ TABLE gt_it_schd_lines INTO
gs_wa_schd_lines INDEX <b>ls_selected_row-row_id</b>.
Regards,
Beejal
**Reward if this helps
‎2007 Feb 19 9:21 AM
Hi,
In the layout set
DATA: w_layout TYPE lvc_s_layo.
<b>w_layout-sel_mode = 'A'.</b> U will get the buttons for selecting multiple rows.
‎2007 Feb 19 9:24 AM
This code will help u to get the selected rows.
Refer this code
INCLUDE <icon>.
* 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->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->handle_user_command FOR o_Alvgrid.
This solved ur problem or not?
Message was edited by:
Judith Jessie Selvi
‎2007 Feb 19 9:27 AM
Hello Bertrand,
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:
<b>
DATA:gs_layout TYPE lvc_s_layo.</b>
<b>gs_layout-sel_mode = 'A'.
</b>CALL METHOD gv_alv->set_table_for_first_display
EXPORTING
<b>is_layout = gs_layout</b>
You can append A,B,C,D based on your requirements.
<b>'A'</b>
Column and row selection
Multiple columns
Multiple rows
The user selects the rows through pushbuttons at the left border of the grid control.
<b>'B'</b>
Simple selection, list box
Multiple columns
Multiple rows
<b>'C'</b>
Multiple selection, list box
Multiple columns
Multiple rows
<b>'D'</b>
Cell selection
Multiple columns
Multiple rows
Any cells
The user selects the rows through pushbuttons at the left border of the grid control.
To get selected rows,you can use the method GET_SELECTED_ROWS.
<b>CALL METHOD gv_alv->get_selected_rows</b>
IMPORTING
ET_INDEX_ROWS =
et_row_no = lt_selected_rows.
<b>READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .</b>
READ TABLE gt_it_schd_lines INTO
gs_wa_schd_lines INDEX <b>ls_selected_row-row_id</b>.
Regards,
Beejal
**Reward if this helps
‎2007 Feb 19 10:08 AM
Thanks for your help,
I have a remaining problem.
The command to valid selection is not inside the alv grid. So the method doesn't catch the selected data of my grid.
Do you know how to resolve this problem.
Thanks in advance,
Bertrand.
‎2007 Feb 19 10:18 AM
Hello Bertrand,
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.
READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .
READ TABLE <b>gt_it_schd_lines</b> INTO
<b>gs_wa_schd_lines</b> INDEX <b>ls_selected_row-row_id</b>.
Here,<b>gt_it_schd_lines</b> is my internal table and based on the selected row-index (<b>ls_selected_row-row_id</b>),I can read my internal table to a work area <b>gs_wa_schd_lines</b>.Now the work area <b>gs_wa_schd_lines</b> will have the selected data of your grid.
If you want to validate the data in the selected row,you can bring it to the work area as shown above (<b>gs_wa_schd_lines</b>) and then validate it.
Regards,
Beejal
**Reward if this helps
‎2007 Feb 19 10:23 AM
Hello,
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).
Thanks for help,
Bertrand
‎2007 Feb 19 10:27 AM
if the command is not in ALV u cant capture the selected rows.
‎2007 Feb 19 10:40 AM
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.