Row Select in ALV
I have an alv that displays data from a few tables.
If I select a row from teh ALV, then the following screen should display some of the fields of the row along with additional information..
I understand that the ON_CLICK event should be used once the row is selected..However, I would appreciate it if someone gave me more info on the same..
Thanks!
Hi,
Tray this:
<i> DATA: lr_table TYPE REF TO cl_salv_wd_table_lead_select,
lr_node TYPE REF TO if_wd_context_node,
lv_field1 TYPE (field1 of your alv table ).
lr_table ?= r_param.
lr_node ?= wd_context->get_child_node( 'NODE_TABLE' ).
CALL METHOD lr_node->get_attribute
EXPORTING
index = lr_table->IF_SALV_WD_TABLE_LEAD_SELECT~INDEX
name = 'FIELD1'
IMPORTING
value = lv_field1.
</i>
With this code, you will have the value of the field 1 of the selected row.
Similar Messages
-
Using row selection in ALV using class cl_salv
Hi,
how to use row selection by using cl_salv classes...
I need to display scarr table in the basic list in ALV wthout using screens and function modules...
On multiple selection of carrid from ALV, need to display flight details from sflight.
Also how to get the selection buttons for corresponding rows.
NOTE : Using class cl_salv*
Thanks,
SiddarthYou may need to look into Rich's example code by the following thread
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01
a® -
Row Selection in ALV on Single click
Hi
Can we read the row in ALV on row selection ? i set gs_layout-sel_mode = 'D'.
My Scenario is as under
there is an ALV on the screen in which i have displayed the data . there is a push button on the screen. User will select the row and then click the push button. on click of that push button selected row should move to the work area.
I am using following method
CALL METHOD g_Grid->SET_TABLE_FOR_FIRST_DISPLAY
Regards
AmmadIf the method [g_grid->get_selected_rows|http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b55312d30911d2b467006094192fe3/frameset.htm] returns no row, then try a [g_grid->get_current_cell|http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b552fad30911d2b467006094192fe3/frameset.htm] (Don't forget the [cl_gui_cfw=>flush|http://help.sap.com/saphelp_erp2004/helpdata/en/06/3fa1879f2811d2bd68080009b4534c/frameset.htm] to synchronize the automation queue.)
Regards,
Raymond -
HI,
I want to make my ALV Grid only single row select enabled, can some one guide me which variable should be set for the same.
Thanks and Regards,
HarshIf you are using OO for alv then
call method grid1->get_selected_rows
importing
et_index_rows = i_sel_alvrows[].
call method cl_gui_cfw=>flush.
describe table i_sel_alvrows lines v_dbcnt.
if i_sel_alvrows[] is initial.
* Info message : Please select a row
message i176. " Please select a row'.
endif.
if v_dbcnt gt 1.
* Info message : Multiple Row Selection not possible
message i177. " Multiple Row Selection not
" possible'
endif.
or if your using REUSE then
form user_command using p_ucomm type sy-ucomm
rs_selfield type slis_selfield.
" Check the rs_selfield-tabindex value here
" you may get some clue here
endform.
a® -
Row Selection in ALV Grid created using CL_GUI_ALV_GRID
Hi,
I have ALV grid using cl_gui_alv_grid. I want to capture the row selection and display the selected rows in 2nd ALV grid (using cl_gui_alv_grid).
Method CALL METHOD Grid->get_selected_rows giving right no. of selected records first time and process these records by POST button and hence shows these records in next alv grid. but when i came back to 1st ALV by pressing BACK button on 2nd ALV then if I again select records on the same 1st ALV grid the same Method CALL METHOD Grid->get_selected_rows fires again. but this times it wouldn't give the selected records. I mean first time this gives me correct no. of selected records but 2nd time wouldn't.
how do I capture the row selection.?
Kindly suggest me. helpful answer will be appreciated.
Thanx in Advance.
RobinHi,
Write this code, you have to free the container.
MODULE user_command_0101 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
c_container->free( ).
c_container1->free( ). " this is the container of secondary list.
clear: r_grid, r_grid1, c_container, c_container1.
LEAVE TO SCREEN 100.
ENDCASE.
Regards and Best wishes. -
How to set only one row selection in ALV GRID DISPLAY
How to set single row selection in grid display
not multiselection.Hi,
In the USER COMMAND, build the code to check the REFRESHED Data & then check the number of records with SEL = 'X'.
If more than single entry found, then raise an error message.
Best regards,
Prashant -
Detect rows selection in ALV using oops
Hi ALL,
I HAVE An ALV OUTPUT OF RECORDS USING OOPS.
NOW I CAN SELECT ONE OR MULTIPLE ROWS OF THE OUTPUT AND I HAVE ADDED A DELETE ICON TO MY TOOL BAR.
I HAVE BACK AND EXIT BUTTON AND I HAVE CODE FOR THE SAME IN PAI.
FOR DELETE ICON SY-UCOMM IS DELE AND CONTROL COMES TO PAI
MY QUESTION IS HOW DO YOU KNOW WHICH ROW OR ROWS ARE SELETEd , IN NORMAL ABAP , a field BOX type c has a value X , but what about in ALV using OOPS.
I have no idea whether my approach is correct or wrong or do i need to something else.
ThanksHi Darren,
This is what i have . Iam new oops so i want to just make sure
method handle_user_command.
§ 3.In event handler method for event USER_COMMAND: Query your
function codes defined in step 2 and react accordingly.
data: lt_rows type lvc_t_row.
case e_ucomm.
when 'DELETE'.
call method g_grid->get_selected_rows
importing et_index_rows = lt_rows.
DATA : WA_LT_ROWS LIKE LINE OF LT_ROWS.
LOOP AT LT_ROWS INTO WA_LT_ROWS.
DELETE I_ZFINAL INDEX WA_LT_ROWS-INDEX.
ENDLOOP.
ENDCASE.
call method g_grid->set_table_for_first_display
exporting
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = g_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
it_toolbar_excluding = pt_exclude
IT_HYPERLINK =
IT_ALV_GRAPHICS =
changing
it_outtab = i_zFINAL
it_fieldcatalog = fieldcat
IT_SORT =
IT_FILTER =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
LET ME KNOW THANKS -
How to capture row selection in ALV output List
Hi experts,
I am displaying some output using ALV function module. My requirement is i have to capture how much rows user has selected in the output list, based on this information i have to perform some actions.
Please help me
Regards,
SachinHi Sachin,
For this first you have to define a variable in your internal table of type c with length 1 and then while building the layout of the ALV, you have to pass this variable name to the layout field BOX_FIELDNAME.
Now when you select a particular row, then the corresponding field in your internal table willl be marked with X. So, for further processing, you can just loop through the table where 'BOX = 'X' and proceed.
For Example:
* Structure for output details
TYPES: BEGIN OF gs_output.
INCLUDE STRUCTURE zas_water_qlty_rep.
TYPES: selected(1) TYPE c,
END OF gs_output.
DATA: object_tab TYPE STANDARD TABLE OF gs_output.
CONSTANTS: lc_selected(8) TYPE c VALUE 'SELECTED'.
lw_layout-box_fieldname = lc_selected. "Field for checkbox
* Local workarea
DATA: lw_layout TYPE slis_layout_alv.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_buffer_active = gc_x
i_bypassing_buffer = gc_x
i_callback_program = lv_repid
i_callback_pf_status_set = g_form_set_pf_stat
i_callback_user_command = lc_uform
i_structure_name = lv_zas_water_qlty_rep
is_layout = lw_layout
it_fieldcat = g_fieldcat_tab[]
it_events = g_events_tab[]
it_event_exit = g_event_exit_tab[]
TABLES
t_outtab = p_object_tab
EXCEPTIONS
program_error = 1
OTHERS = 2.
Hope this helps.
Regards,
Phani. -
Hi ,
Have a requirement where in all the rows in ALV should be selected defaultly.
Thanks.
Regards,
SuvarnaHi suvarna,
just add ,
wa_layout-sel_mode = c_a.
this to ur ALV layout.
u will get default selection mode.
here c_a is 'A'.
Regards,
kk. -
Hi
I have a requirement in FM ALV where I have a search box and the user can search for criteria. I then search my underlying data table and if the data is found I want to put the row focus on the particular row. How do I set row focus in FM ALV?
Example:
User searches for PERNR 778.
778 is found at SY-TABIX 440. I now want the ALV to focus on row 440.Hi Brad,
Try this way. It works. I have developed sample program for you. Change your program accordingly.
<pre>REPORT zvenkat_alv_list.
DATA: BEGIN OF i_mard OCCURS 0,
color(3) TYPE c, "color
werks TYPE mard-werks,
lgort TYPE mard-lgort,
matnr TYPE mard-matnr,
insme TYPE mard-insme,
einme TYPE mard-einme,
speme TYPE mard-speme,
END OF i_mard.
Types Pools
TYPE-POOLS:
slis.
Types
TYPES:
t_fieldcat TYPE slis_fieldcat_alv,
t_events TYPE slis_alv_event,
t_layout TYPE slis_layout_alv.
Workareas
DATA:
w_fieldcat TYPE t_fieldcat,
w_events TYPE t_events,
w_layout TYPE t_layout.
Internal Tables
DATA:
i_fieldcat TYPE STANDARD TABLE OF t_fieldcat,
i_events TYPE STANDARD TABLE OF t_events.
START-OF-SELECTION.
PERFORM get_data_from_database .
PERFORM build_fieldcatalog.
w_layout-info_fieldname = 'COLOR'. "color
PERFORM display_data.
*& Form get_data_from_database
FORM get_data_from_database .
CLEAR :i_mard,i_mard[].
SELECT werks lgort matnr insme einme speme
FROM mard
INTO CORRESPONDING FIELDS OF TABLE i_mard
UP TO 100 ROWS.
ENDFORM. " get_data_from_database
*& Form build_fieldcatalog
FORM build_fieldcatalog .
CLEAR :w_fieldcat,i_fieldcat[].
PERFORM build_fcat USING:
"Field Int Tab Text
'WERKS' 'I_MARD' 'WERKS',
'LGORT' 'I_MARD' 'LGORT',
'MATNR' 'I_MARD' 'MATNR',
'INSME' 'I_MARD' 'INSME',
'EINME' 'I_MARD' 'EINME',
'SPEME' 'I_MARD' 'SPEME'.
ENDFORM. " build_fieldcatalog
*& Form display_data
FORM display_data .
DATA :program LIKE sy-repid VALUE sy-repid.
SORT i_mard BY werks.
DELETE ADJACENT DUPLICATES FROM i_mard COMPARING werks.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = program
i_callback_user_command = 'USER_COMMAND'
is_layout = w_layout
it_fieldcat = i_fieldcat
it_events = i_events
TABLES
t_outtab = i_mard.
ENDFORM. " display_data
*& Form BUILD_FCAT
FORM build_fcat USING l_field l_tab l_text.
w_fieldcat-fieldname = l_field.
w_fieldcat-tabname = l_tab.
w_fieldcat-seltext_m = l_text.
IF l_field = 'WERKS'.
w_fieldcat-hotspot = 'X'.
ENDIF.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
ENDFORM. " BUILD_FCAT
*& Form USER_COMMAND
FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
IF r_ucomm = '&IC1'.
READ TABLE i_mard WITH KEY werks = rs_selfield-value.
IF sy-subrc = 0.
i_mard-color = 'C31'.
MODIFY i_mard INDEX sy-tabix.
ENDIF.
rs_selfield-refresh = 'X'.
ENDIF.
ENDFORM. "USER_COMMAND</pre>
Thanks
venkat.O -
Default row selected in alv grid
Hi Everyone,
I have couple of alv screens. By default the topmost cell is highlighted in the first grid, the data of second grid is dependant on the first one. So if the topmost record is selected by default in first grid, i want to highlight its corresponding records in the second grid.
How do I achieve this.
Any help on this will be of great use to me.
Thanks in advance,
Prashant.In PAI,
MODULE user_command_9001 INPUT.
REFRESH i_fieldrows.
<b>CALL METHOD o_alvgrid->get_selected_rows
IMPORTING
et_index_rows = i_fieldrows.</b> LOOP AT i_fieldrows INTO w_fieldrows.
READ TABLE i_output INTO w_output INDEX w_fieldrows-index.
ENDLOOP.
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
WHEN 'MD04'.
IF w_output-matnr IS INITIAL.
MESSAGE i001 WITH text-e07.
ELSE.
SET PARAMETER ID 'MAT' FIELD w_output-matnr.
SET PARAMETER ID 'WRK' FIELD w_output-werks.
CALL TRANSACTION 'md04' AND SKIP FIRST SCREEN .
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT
Similarly in the next screen PAI,
use
CALL METHOD o_alvgrid->set_selected_rows
IMPORTING
et_index_rows = i_fieldrows. -
Hi All.
I am trying to set multiple selection on in ALV using the method SET_SELECTION_MODE of IF_WD_SELECT_OPTIONS. (if_salv_wd_table_settings)
But it is always resulting in a dump saying that :
Selection type Multi is not allowed in combination with the selection Single of the data node
Now how can we change the context of the ALV?
What am i doing wrong here?
Thanks.Hi this works fine here:
data: lr_table_settings type ref to if_salv_wd_table_settings.
lr_table_settings->set_read_only( abap_false ).
lr_table_settings->set_enabled( abap_true ).
lr_table_settings->set_selection_mode( CL_WD_TABLE=>e_selection_mode-multi ).
The node i bound to the ALV has selection 0..n.
Cheers,
Sascha -
Get Selections From ALV on Multiple Selection Mode
Hi,
How can i get values of selected rows from ALV that has selection '0..n' (multiple selection) ?
Can somebody help me pls?
Thanks.Hi Nurullah,
Steps to make multiple rows selectable in ALV:
1) Create the selection property of the node that you are binding to the DATA node as o..n
2) Un-check the, "Initialization Lead Selection" checkbox for the node which you are using to bind to the DATA node
3) In the WDDOINIT method specify the ALV's selection mode as MULTI_NO_LEAD. It is important that you set the selection mode to MULTI_NO_LEAD or else in the end you would be capturing 1 row lesser than the total number of rows the user has selected. This is because 1 of the rows would have the LeadSelection property & our logic wouldnt be reading the data for that row. Check the example code fragment as shown below:
DATA lo_value TYPE REF TO cl_salv_wd_config_table.
lo_value = lo_interfacecontroller->get_model( ).
CALL METHOD lo_value->if_salv_wd_table_settings~set_selection_mode
EXPORTING
value = cl_wd_table=>e_selection_mode-MULTI_NO_LEAD.
Steps to get the multiple rows selected by the user
In order to get the multiple rows which were selected by the user you will just have to call the get_selected_elements method of if_wd_context_node. So as you can see its no different from how you would get the multiple rows selected by the user in a table ui element. First get the reference of the node which you have used to bind to the ALV & then call this method on it. Check the example code fragment below:
METHOD get_selected_rows .
DATA: temp TYPE string.
DATA: lr_node TYPE REF TO if_wd_context_node,
wa_temp TYPE REF TO if_wd_context_element,
ls_node1 TYPE wd_this->element_node_flighttab,
lt_node1 TYPE wd_this->elements_node_flighttab.
lr_node = wd_context->get_child_node( name = 'NODE_FLIGHTTAB' ).
" This would now contain the references of all the selected rows
lt_temp = lr_node->get_selected_elements( ).
LOOP AT lt_temp INTO wa_temp.
" Use the references to get the exact row data
CALL METHOD wa_temp->get_static_attributes
IMPORTING
static_attributes = ls_node1.
APPEND ls_node1 TO lt_node1.
CLEAR ls_node1.
ENDLOOP.
ENDMETHOD.
Hope this helps resolve your problem.
Regards,
Uday -
How to process Line Selection on ALV Table in ABAP WebDynpro
Hi there,
I have a view with an ALV table whose context node retrieves its data from a Service Call for a method.
The method provides certain data of a database table which the ALV displays.
Now I would like to be able to select one row of that ALV table and after pressing a button or doubleclicking on the row or whatever a different view (as for me it is also ok on the same view) should appear to display the details of that selection.
I only need to know how to retrieve the selected data.
Or its index within the internal table.
I am already looking for hours for a useful thread and actually there is one which obviously is about a similar issue apart from the multiple selection part:
How to process multiple row selection in ALV table in Wendynpro ABAP? Help!
but i am afraid that i don't understand it. Or at least I misunderstand it since it does not work with me.
The system example mentioned in the thread does not help me either because it somehow does not correspond to my needs, does it?
It would be GREAT if somebody could help me with that. Please keep it simple for I am not an expert in webdynpro yet (obviously ^^) and also please explain in detail what I have to do with the context nodes since I am not sure whether the selection is stored in my already existing node or whether I need a special one for that.
Thanks!!
christinaHi Christina,
If you just want to get one column data of the line that user clicked, use the Web Dynpro Code Wizard to Read Context of attibute you needed, then you will get code as follow:
* Define data for read attribute
node_alv TYPE REF TO if_wd_context_node,
elem_alv TYPE REF TO if_wd_context_element,
stru_alv TYPE if_view_display=>element_alv ,
item_column_name LIKE stru_alv-column_name.
* navigate from <CONTEXT> to <ALV> via lead selection
node_alv = wd_context->get_child_node( name = if_view_display=>wdctx_alv ).
* get element via lead selection
elem_alv = node_alv->get_element( ).
* get single attribute
elem_alv->get_attribute(
EXPORTING
name = `COLUMN_NAME'
IMPORTING
value = item_column_name ).
The value of column_name is stored in item_column_name.
If you need the index that the user clicked, try this:
* Definition of field symbol for index
FIELD-SYMBOLS : <fs_index> TYPE data.
* Get the selected index
ASSIGN r_param->index->* TO <fs_index>.
The index of clicked line is stored in field symbol <fs_index>.
Hope it will help.
Best Regards,
Stephanie -
how to do multiple rows selection in alv's....
do you use the function or the alv grid control (i.e. the classes)?
bye
enzo
Maybe you are looking for
-
How to access properties of symbols in loaded SWF?
I'm making the migration from Flash to Flex, but I'm running into a dead end on one particular area: accessing and manipulating properties of symbols in a loaded SWF. The SWF is actually a simple library of a detailed parts illustration. I would like
-
Is there any way of finding out whether an e-mail I have sent has been opened?
No further details - apologies if there's a simple solution, I'm new to this.
-
No response to my IQ506 problems
It is interesting that no-one has been able to post solutions to my on-going problems with my new IQ506. These are serious design faults which HP has yet to address and should not exist in a new PC costing $1,500!
-
hi I am working with B17 SP9(SAPKW70009. When i click F1 for help, it is displaying in different language other than english. What should i do to make the help window display in english? Is there any note that i can follow or any configuration that i
-
Have iMovie 09, Install Older Versions, too
I have iMovie 09 installed but I cannot add additional transitions and effects with this version. I understand you can add them to older versions. Is it possible to download older versions for free anywhere? Also, how would I install an older version