2008 Jan 07 7:45 AM
Hi all,
I need code on:
Double click on alv column and highlight the whole line to grey.
Any help?
Thanks
Hi gray,
For coloring the whole row,
in the internal table add another field
eg
color(4) type c.
data: g_col(4) type c.
l_char type c.
loop at itab into wa where condition.
ind = sy-tabix.
l_char = cl_gui_resources=>list_col_negative.
CONCATENATE 'C' " = constant
l_char "color
'0' "intensified 0=off 1=on
'0' "inverse 0=off 1=on
INTO g_col.
ITAB-color = g_col.
modify itab from wa index ind
transporting color.
endloop.
and in the layout field add this.
data: layout type lvc_s_layo.
layout- info_fname = 'COLOR'.
and pass it to the display the table in alv container.
and for implementing double click whenever the row is colored use this condition.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_double_click.
READ TABLE itab into wa_itab INDEX e_row-index INTO w_string.
if wa_itab-color = 'C300'.
write the code for double click.
endif.
ENDMETHOD. "HANDLE_DOUBLE_CLICK
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
regards,
Santosh Thorat
2008 Jan 07 7:51 AM
HI,
Use a class and handler method as given below
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
METHODS: handle_button_click
FOR EVENT button_click OF cl_gui_alv_grid
IMPORTING es_col_id es_row_no.
ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_double_click.
READ TABLE itab INDEX e_row-index INTO w_string.
write the code what u want to execute.
ENDMETHOD. "HANDLE_DOUBLE_CLICK
after this u have to set handler for the double click event to get triggered.
u can write it like this.
create a object of the above class and set the handler.
data: w_event_receiver type ref to lcl_event_receiver.
CREATE OBJECT w_event_receiver.
SET HANDLER w_event_receiver->handle_double_click FOR w_grid.
regards,
Santosh Thorat
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
2008 Jan 07 9:43 AM
Hi i got the code for double click. I must to implement whenever i double on a field the whole row is color.... Hw can i accomplish this. .....thank
2008 Jan 08 5:37 AM
Hi gray,
For coloring the whole row,
in the internal table add another field
eg
color(4) type c.
data: g_col(4) type c.
l_char type c.
loop at itab into wa where condition.
ind = sy-tabix.
l_char = cl_gui_resources=>list_col_negative.
CONCATENATE 'C' " = constant
l_char "color
'0' "intensified 0=off 1=on
'0' "inverse 0=off 1=on
INTO g_col.
ITAB-color = g_col.
modify itab from wa index ind
transporting color.
endloop.
and in the layout field add this.
data: layout type lvc_s_layo.
layout- info_fname = 'COLOR'.
and pass it to the display the table in alv container.
and for implementing double click whenever the row is colored use this condition.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_double_click.
READ TABLE itab into wa_itab INDEX e_row-index INTO w_string.
if wa_itab-color = 'C300'.
write the code for double click.
endif.
ENDMETHOD. "HANDLE_DOUBLE_CLICK
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
regards,
Santosh Thorat
2008 Jan 07 7:53 AM
hi
sample code for Double Click:
Top Declaration:
--
CLASS lcl_handle_events DEFINITION DEFERRED.
----
CLASS lcl_handle_events DEFINITION
----
Define a local class to handle the double click on the ALV
----
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_user_command FOR EVENT added_function
OF cl_salv_events
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_user_command FOR EVENT added_function
OF cl_salv_events
IMPORTING e_salv_function,
on_double_click FOR EVENT double_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS.
CLASS lcl_handle_events DEFINITION DEFERRED.
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_user_command FOR EVENT added_function
OF cl_salv_events
IMPORTING e_salv_function,
on_double_click FOR EVENT double_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS.
*******NOW THE FORM EVENT
***********N UR PERFORM FOR ALV:
o_events = o_r_table->get_event( ).
CREATE OBJECT o_l_handler.
SET HANDLER o_l_handler->on_double_click FOR o_events.
ALL THIS BEFOR THE DISPLAY OF ALV
MPLEMENTATION OF CLASS:
CLASS lcl_handle_events IMPLEMENTATION.
METHOD on_double_click.
PERFORM handle_user_commnd USING row column .
ENDMETHOD.
********THEN A PERFORM TO HANDLE Dc
FORM handle_user_commnd USING p_alv_row TYPE salv_de_row
p_alv_column TYPE salv_de_column.
*********NOW DO WTEVER U WANT
EXAMPLE:
READ TABLE it_output INTO wa_output INDEX p_alv_row.
IF sy-subrc = 0.
CASE p_alv_column.
WHEN 'MATNR' OR 'MAKTX' OR 'MEINS'.
SET PARAMETER ID 'MXX' FIELD 'K'.
SET PARAMETER ID 'MAT' FIELD wa_output-matnr.
SET PARAMETER ID 'WRK' FIELD wa_output-werks.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |