Skip to Content
author's profile photo Former Member
Former Member

ALV

Hi all,

I need code on:

Double click on alv column and highlight the whole line to grey.

Any help?

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 07: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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 07:53 AM

    hi

    sample code for Double Click:

    Top Declaration:

    --


    [CLASSES]-

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.