08-17-2005 9:32 PM
Hi Everyone,
Can anyone plese let me how to get the cursor position on the alv grids,
I have two alv grids, and i want to get the cursor position on them.
Thanks in advance,
Prabs.
08-17-2005 9:52 PM
Hi Prabhakarn,
Did you check the methods 'GET_SELECTED_...' in 'CL_GUI_ALV_GRID' .. there are lot of options available..
Good Luck,
Suresh Datti
08-17-2005 10:16 PM
Hi Suresh,
I used this and tried out, but unfortunately could not get it. If u have some sample code to achieve this it would be of great use to me.
Thanks,
Prabs.
08-18-2005 5:10 AM
Hi,
Here is a sample code.For example, i have inserted a button in the toolbar of the ALV grid to display the selected row (either single or multiple rows).
data: ok_code like sy-ucomm,
i_cont_name type scrfname value 'ALVGRIDCONTROL',
i_grid type ref to cl_gui_alv_grid,
i_cont_custom type ref to cl_gui_custom_container.
data: it_field type lvc_s_fcat,
it_layout type lvc_s_layo,
it_variant type disvariant,
it_event_receiver type ref to lcl_event_receiver,
sel_row type lvc_t_row,
sel_row_table like lvc_s_row.
class lcl_event_receiver definition.
public section.
methods:
handle_toolbar for event toolbar of cl_gui_alv_grid
importing e_object e_interactive,
handle_user_command for event user_command of cl_gui_alv_grid
importing e_ucomm.
endclass.
class lcl_event_receiver implementation.
method handle_toolbar.
data: ls_toolbar type stb_button.
clear ls_toolbar.
move 'DISP' to ls_toolbar-function.
move 'DISPLAY' to ls_toolbar-text.
move icon_select_all to ls_toolbar-icon.
move 'DISPLAY' to ls_toolbar-quickinfo.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
endmethod.
method handle_user_command.
case e_ucomm.
when 'DISP'.
perform disp2_selected_information.
endcase.
start-of-selection.
select * from zc7_employee into corresponding fields of table itab_emp.
call screen 3010.
end-of-selection.
module status_3010 output.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
if i_cont_custom is initial.
create object i_cont_custom
exporting
container_name = i_cont_name.
create object i_grid
exporting
i_parent = i_cont_custom.
create object it_event_receiver.
set handler it_event_receiver->handle_toolbar for i_grid.
set handler it_event_receiver->handle_user_command for i_grid.
call method i_grid->set_table_for_first_display
exporting
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
i_structure_name = 'ZC7_EMPLOYEE'
is_variant = it_variant
i_save = x_save
I_DEFAULT = 'X'
is_layout = it_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
changing
it_outtab = itab_emp[]
IT_FIELDCATALOG =
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
form disp2_selected_information.
clear wa_itab2.
data : i_lines type i.
Reading the index of the selected row in the ALV grid.
call method i_grid->get_selected_rows
importing
et_index_rows = sel_row.
Check whether a row is selected or not. If not it popups a dialog box as warning to select a row.
describe table sel_row lines i_lines.
if i_lines = 0.
call function 'POPUP_TO_DISPLAY_TEXT'
exporting
textline1 = 'Choose a row to proceed!'.
exit.
endif.
Reads the selected rows into work area for display
loop at sel_row into sel_row_table.
read table itab_emp index sel_row_table-index into
wa_itab2.
call screen 3011 starting at 10 5.
endloop.
endform.
module user_command_3011 input.
case ok_code.
when 'CONT'.
leave to screen 0.
endcase.
endmodule. " USER_COMMAND_3011 INPUT
Hope it helps you.
Thanks&Regards,
Ruthra.R
08-18-2005 7:28 AM
call method cl_gui_control=>set_focus
exporting control = w_grid.
w_grid is ur gid name.
Try this.