On click event in ALV table

Hai,
I have an ALV table with 5 rows.In the column i have button for all the rows.Suppose if i click the button in 4 th row i want to get the index of the row choosed.Can anyone tell me how to do it ot if you have the code please help me.
Regards,
Ram Siv

Hello,
I am not too sure for your requirement, but what I could understood is "You have created an ALV table of buttons and have assigned with same onaction method, once cliked on any of the button, you want to figure out which button has been clicked?" If this is the casse then there is a very easy way to find out where the click has taken place, use the code below in the on action method of the button in  the alv table.
data: lo_context_element type ref to IF_WD_CONTEXT_ELEMENT,
          lv_clicked_row       type int4.
check wdevent is bound.
lo_context_element =  wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
check lo_context_element is bound.
lv_clicked_row = lo_context_element->get_index( ).
Once this is executed, lv_clicked_row would contain the index of the table row where the user have clicked, this value can be further used for business logic derivation purpose.
Please let me know if this does not help!
Thanks & Regards
Abir Chakraborty

Similar Messages

  • About double click event in ALV report

    Hi all,
    I want to program a double-click event in ALV reprot.
    I am not suppose to use module pool approach for the same.
    If a user double clicks on the any of the row of ALV report, the transaction should get called.
    Again, I am using function 'REUSE_ALV_GRID_DISPLAY' for displaying ALV.
    Can you please help me to solve this?
    Thanks,
    -Siddhi

    Hi Sidhi,
    You can do it easily by using Reuse_ALV_GRID_DISPALY.
    The User Command subroutine which you pass to this function module in that you can check which field is selected and what is the value of that and also you can get the table index.
    I am giving you a code example where interactivity of ALV report is done .
    *& Report  ZRAIL_LOT_REPORT
    REPORT  zrail_lot_report.
    TABLES :qals,aufk.
    TYPE-POOLS:slis.
    TYPES:BEGIN OF x_lot,
          sel(1)   TYPE c,                    "SELECTION
          prueflos TYPE qals-prueflos,        "INSPECTION LOT NUMBER
          werk     TYPE qals-werk,            "PLANT
          losmenge TYPE qals-losmenge,        "LOT QUANTITY
          mengeneinh TYPE qals-mengeneinh,   "BASE UNIT OF MEASURE FOR THE INSPECTION LOT QUANTITY
          matnr   TYPE  qals-matnr,          " MATERIAL NO. ATTACHED TO ORDER
          zzequnr  TYPE qals-zzequnr,         "EQUIPMENT NO.
          zzassembly TYPE qals-zzassembly,    "ASSEMBLY
          herkunft  TYPE qals-herkunft,       "INSPECTION LOT ORIGIN
          aufnr     TYPE qals-aufnr,          "ORDER NO.
          sttxt     TYPE qals_d02-sttxt,      "LOT STATUS
          objnr     TYPE qals-objnr,          "OBJECT NUMBER
          enstehdat TYPE qals-enstehdat,      "lot creation date
          pruefer   TYPE qamr-pruefer,        "Name of the Inspector
          END OF x_lot.
    TYPES:BEGIN OF x_ordmat,
          aufnr TYPE aufk-aufnr,             "Order No.
          equnr TYPE afih-equnr,             "Equipment No. attached to Order
          zmatnr TYPE aufk-zmatnr,           "Material No. attached to Order
          bautl  TYPE afih-bautl,            "Assembly attached to Order
          END OF x_ordmat.
    TYPES:BEGIN OF x_status,
          objnr TYPE jest-objnr,
          stat  TYPE jest-stat,
          txt04 TYPE tj02t-txt04,
          END OF x_status.
    DATA:it_qals TYPE STANDARD TABLE OF x_lot,
         wa_qals TYPE x_lot.
    DATA:it_ordmat TYPE TABLE OF x_ordmat,
         wa_ordmat TYPE x_ordmat.
    DATA:it_status TYPE STANDARD TABLE OF x_status,
         wa_status TYPE x_status.
    DATA:mytabix TYPE sy-tabix.
    DATA: wa_layout   TYPE slis_layout_alv,
          wa_fieldcat TYPE slis_fieldcat_alv,
          it_fieldcat TYPE TABLE OF slis_fieldcat_alv,
          it_fcat TYPE TABLE OF slis_fieldcat_alv.
    DATA:mytabix1 TYPE sy-tabix.
    SELECTION-SCREEN BEGIN OF BLOCK  b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_werks FOR qals-werk,
                    s_zmatnr FOR aufk-zmatnr,
                    s_assbly FOR qals-zzassembly,
                    s_equnr FOR qals-zzequnr,
                    s_lotor FOR qals-herkunft,
                    s_lotdat FOR qals-enstehdat.
    SELECTION-SCREEN END OF BLOCK b1.
    INITIALIZATION.
      s_lotdat-low = sy-datum - 7.
      s_lotdat-high = sy-datum.
      APPEND s_lotdat.
    START-OF-SELECTION.
      PERFORM get_data_qals.
      PERFORM build_fieldcat.
      PERFORM display_data.
      EXIT.
    END-OF-SELECTION.
    *&      Form  get_data_qals
          text
    -->  p1        text
    <--  p2        text
    FORM get_data_qals .
      IF it_qals[] IS INITIAL.
        SELECT a~prueflos
               a~werk
               a~losmenge
               a~mengeneinh
               a~zzequnr
               a~zzassembly
               a~herkunft
               a~aufnr
               a~objnr
               a~matnr
               a~enstehdat
               b~pruefer
               FROM qals AS a INNER JOIN qamr AS b
               ON aprueflos = bprueflos
               INTO CORRESPONDING FIELDS OF TABLE it_qals
               WHERE werk IN s_werks
               AND   zzassembly IN s_assbly
               AND   zzequnr    IN s_equnr
               AND   herkunft   IN s_lotor
               AND   enstehdat  IN s_lotdat.
      ENDIF.
      IF it_ordmat[] IS INITIAL.
        SELECT a~aufnr
               a~zmatnr
               b~bautl
               b~equnr
               FROM aufk AS a INNER JOIN afih AS b
               ON aaufnr = baufnr
               INTO CORRESPONDING FIELDS OF TABLE it_ordmat FOR ALL ENTRIES IN it_qals
               WHERE a~aufnr = it_qals-aufnr
                AND zmatnr IN s_zmatnr.
      ENDIF.
      IF it_status[] IS INITIAL.
        SELECT a~objnr
               a~stat
               b~txt04
               FROM  tj02t AS b
               INNER JOIN jest AS a ON bistat = astat
               INTO CORRESPONDING FIELDS OF TABLE it_status FOR ALL ENTRIES IN it_qals
               WHERE a~objnr = it_qals-objnr
               AND   b~spras = sy-langu
               AND   a~inact = space.
      ENDIF.
      LOOP AT it_qals INTO wa_qals.
        mytabix = sy-tabix.
        READ TABLE it_ordmat INTO wa_ordmat WITH KEY aufnr = wa_qals-aufnr.
        IF sy-subrc = 0.
          IF wa_qals-herkunft = '14'.
            wa_qals-matnr = wa_ordmat-zmatnr.
            wa_qals-zzequnr =  wa_ordmat-equnr.
            wa_qals-zzassembly = wa_ordmat-bautl.
            MODIFY it_qals FROM wa_qals INDEX  mytabix TRANSPORTING matnr zzassembly zzequnr.
          ENDIF.
        ENDIF.
        LOOP AT it_status INTO wa_status WHERE objnr = wa_qals-objnr.
          CONCATENATE wa_qals-sttxt wa_status-txt04 INTO wa_qals-sttxt SEPARATED BY space.
          CLEAR :wa_status.
        ENDLOOP.
        MODIFY it_qals FROM wa_qals INDEX  mytabix TRANSPORTING sttxt.
        CLEAR :wa_qals,wa_ordmat,mytabix.
      ENDLOOP.
      IF s_zmatnr[] IS NOT INITIAL.
        DELETE it_qals WHERE matnr IS INITIAL.
      ENDIF.
    ENDFORM.                    " get_data_qals
    *&      Form  build_fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM build_fieldcat .
      wa_layout-zebra = 'X'.
      wa_layout-colwidth_optimize = 'X'.
      wa_layout-box_fieldname = 'SEL'.
      wa_layout-box_tabname = 'IT_QALS'.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
        I_PROGRAM_NAME               =
          i_internal_tabname           = 'IT_QALS'
          i_structure_name             = 'QALS_D02'
        I_CLIENT_NEVER_DISPLAY       = 'X'
        I_INCLNAME                   =
        I_BYPASSING_BUFFER           =
        I_BUFFER_ACTIVE              =
        CHANGING
          ct_fieldcat                  = it_fieldcat
      IF sy-subrc = 0.
        LOOP AT  it_fieldcat INTO wa_fieldcat.
          CASE  wa_fieldcat-fieldname .
            WHEN  'PRUEFLOS'.
              wa_fieldcat-col_pos = 1.
              wa_fieldcat-hotspot = 'X'.
              APPEND wa_fieldcat TO it_fcat.
            WHEN   'WERK'.
              wa_fieldcat-col_pos = 3.
              APPEND wa_fieldcat TO it_fcat.
            WHEN  'LOSMENGE'.
              wa_fieldcat-col_pos = 4.
              wa_fieldcat-no_out = ''.
              APPEND wa_fieldcat TO it_fcat.
            WHEN  'MENGENEINH'.
              wa_fieldcat-col_pos = 5.
              wa_fieldcat-no_out = ''.
              APPEND wa_fieldcat TO it_fcat.
            WHEN 'ZZEQUNR'.
              wa_fieldcat-col_pos = 6.
              wa_fieldcat-no_out = ''.
              wa_fieldcat-hotspot = 'X'.
              APPEND wa_fieldcat TO it_fcat.
            WHEN  'ZZASSEMBLY'.
              wa_fieldcat-col_pos = 7.
              wa_fieldcat-no_out = ''.
              wa_fieldcat-hotspot = 'X'.
              APPEND wa_fieldcat TO it_fcat.
            WHEN  'HERKUNFT'.
              wa_fieldcat-col_pos = 8.
              APPEND wa_fieldcat TO it_fcat.
            WHEN  'AUFNR'.
              wa_fieldcat-col_pos = 9.
              wa_fieldcat-hotspot = 'X'.
              APPEND wa_fieldcat TO it_fcat.
            WHEN  'ENSTEHDAT'."enstehdat
              wa_fieldcat-col_pos = 10.
              APPEND wa_fieldcat TO it_fcat.
            WHEN  'STTXT'.
              wa_fieldcat-col_pos = 12.
              wa_fieldcat-hotspot = 'X'.
              APPEND wa_fieldcat TO it_fcat.
            WHEN OTHERS.
          ENDCASE.
          CLEAR wa_fieldcat.
        ENDLOOP.
        wa_fieldcat-fieldname = 'MATNR'.
        wa_fieldcat-tabname  =  'IT_QALS'.
        wa_fieldcat-col_pos = 2.
        wa_fieldcat-ref_tabname = 'AUFK'.
        wa_fieldcat-hotspot = 'X'.
        wa_fieldcat-seltext_l = 'Material No.'.
        APPEND wa_fieldcat TO it_fcat.
        wa_fieldcat-fieldname = 'PRUEFER'.
        wa_fieldcat-tabname  =  'IT_QALS'.
        wa_fieldcat-col_pos = 11.
        wa_fieldcat-ref_tabname = 'QAMR'.
        wa_fieldcat-seltext_l = 'Name of the Inspector'.
        APPEND wa_fieldcat TO it_fcat.
      ENDIF.
    ENDFORM.                    " build_fieldcat
    *&      Form  display_data
          text
    -->  p1        text
    <--  p2        text
    FORM display_data .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
       i_callback_program                = 'ZRAIL_LOT_REPORT'
      I_CALLBACK_PF_STATUS_SET          = ' '
         i_callback_user_command           = 'USER_COMMAND'
         is_layout                         = wa_layout
          it_fieldcat                       = it_fcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
        TABLES
          t_outtab                          = it_qals
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " display_data
    *&      Form  USER_COMMAND
          text
         -->R_UCOMM      text
         -->RS_SELFIELD  text
    FORM user_command USING r_ucomm TYPE sy-ucomm  rs_selfield TYPE slis_selfield.
      CASE rs_selfield-fieldname  .
        WHEN 'PRUEFLOS'.
          SET PARAMETER ID 'QLS' FIELD rs_selfield-value.
          CALL TRANSACTION 'QA03' AND SKIP FIRST SCREEN.
        WHEN 'ZZEQUNR'.
          SET PARAMETER ID 'EQN' FIELD  rs_selfield-value.
          CALL TRANSACTION 'IE03' AND SKIP FIRST SCREEN.
        WHEN 'ZMATNR'.
          SET PARAMETER ID 'MAT' FIELD rs_selfield-value.
          CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
        WHEN 'ZZASSEMBLY'.
          SET PARAMETER ID 'MAT' FIELD rs_selfield-value.
          CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
        WHEN 'AUFNR'.
          SET PARAMETER ID 'ANR' FIELD rs_selfield-value.
          CALL TRANSACTION 'IW33' AND SKIP FIRST SCREEN.
        WHEN 'STTXT'.
          MOVE rs_selfield-tabindex TO mytabix1.
          PERFORM show_status.
      ENDCASE.
    ENDFORM.                    "USER_COMMAND
    *&      Form  show_status
          text
    -->  p1        text
    <--  p2        text
    FORM show_status .
      DATA:it_systat TYPE TABLE OF bapi2045ss,
           wa_sysstat TYPE bapi2045ss,
           it_bapi2045us TYPE TABLE OF bapi2045us.
      DATA:it_fsys TYPE TABLE OF slis_fieldcat_alv.
      DATA:insplot TYPE bapi2045d_il0-insplot.
      DATA:language TYPE bapi2045la.
      CLEAR wa_qals.
      READ TABLE it_qals INTO wa_qals INDEX mytabix1.
      insplot = wa_qals-prueflos.
      language-langu = sy-langu.
      CALL FUNCTION 'BAPI_INSPLOT_GETSTATUS'
        EXPORTING
          number        = insplot
          language      = language
        TABLES
          system_status = it_systat
          user_status   = it_bapi2045us.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name     = 'ZRAIL_LOT_REPORT'
          i_internal_tabname = 'IT_SYSTAT'
          i_structure_name   = 'BAPI2045SS'
        CHANGING
          ct_fieldcat        = it_fsys.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = 'ZRAIL_LOT_REPORT'
          it_fieldcat        = it_fsys
        TABLES
          t_outtab           = it_systat.
    ENDFORM.                    " show_status
    IIn the subrouitne the User command the Parameter rs_selfield will give you the selected or clicked field and its value its record no .
    I hope this will help you.

  • Handling Right & Left Click Events in ALV Grid

    Hi Friends,
    Please give me the idea how to handle Right & Left mouse Click Events in ALV Grid.
    My requirement is that when i click on the grid i need to pop up a message.
    Eagerly waiting for your replies
    Thanks
    Satish

    you have to Define a class and implement event handler methods for this purpose.
    and the following events can help.
    LEFT_CLICK_DESIGN
    LEFT_CLICK_RUN
    Regards
    Raja

  • Double click event in ALV Display

    Hi
      I am using Reuse_alv_grid_display for dis[playing ALV. Now I want to handle double click event on a perticular Single column.
    Pls provide code.

    Hi,
    Check this example..If you double click on the purchase order field, it will take you to the corresponding PO in ME23N..
    TYPE-POOLS: slis.
    DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: BEGIN OF wa_ekko,
    ebeln like ekko-ebeln,
    ekorg like ekko-ekorg,
    ekgrp like ekko-ekgrp,
    END OF wa_ekko.
    DATA: v_repid TYPE syrepid.
    v_repid = sy-repid.
    DATA it_ekko LIKE STANDARD TABLE OF wa_ekko WITH HEADER LINE.
    SELECT * UP TO 100 ROWS
    FROM ekko
    INTO CORRESPONDING FIELDS OF TABLE it_ekko.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
         EXPORTING
              i_program_name     = v_repid
              i_internal_tabname = 'WA_EKKO'
              i_inclname         = v_repid
         CHANGING
              ct_fieldcat        = gt_fieldcat.
    Pass the program.
    v_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
         EXPORTING
              i_callback_program      = v_repid
              it_fieldcat             = gt_fieldcat
              i_callback_user_command = 'USER_COMMAND'
         TABLES
              t_outtab                = it_ekko.
          FORM display_detail                                           *
    -->  UCOMM                                                         *
    -->  SELFIELD                                                      *
    FORM user_command USING ucomm LIKE sy-ucomm
    selfield TYPE slis_selfield.
      IF ucomm = '&IC1' AND selfield-fieldname = 'EBELN'.
        READ TABLE it_ekko INDEX selfield-tabindex.
        IF sy-subrc = 0.
          SET PARAMETER ID 'BES' FIELD it_ekko-ebeln.
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDIF.
    ENDFORM.
    Thanks,
    Naren

  • Double click event in alv oops

    Hi,
    can any one please help me out... i dont know how to call events in alv oops...so can any one provide me with some help..
    My requirment is i have to generate a mail grid containing customer details and if i double click on a customer it should go to the transaction XD03 second screen.....

    u have to declae an event like this.
    class event_receiver definition.
      public section.
        methods handle_double_click
          for event double_click of cl_gui_alv_grid
          importing e_row.
    endclass.
    then u have to implement it in the implementation
    class lcl_event_receiver implementation.
      method lmt_handle_double_click.
        perform double_click using e_row
                                   tbl_final_display.
      endmethod.                   
    endclass.
    form double_click
            using fu_e_row             type lvc_s_row
                  fu_tbl_final_display type typ_tbl_display.
      read table fu_tbl_final_display into l_h_tbl_final_display
                              index fu_e_row-index.
      if sy-subrc = 0.
        set parameter id cns_aun field l_h_tbl_final_display-vbeln.
        call transaction cns_trans and skip first screen.
      endif.
    endform.
    hope it will help u

  • How to trigger single click event in ALV

    Hi Experts,
          I am trying to raise an event in a module pool program whereby an event will be triggered on  a single click of a particular row in the ALV.
       My requirement is that in the table display , which is being handled OO method, once the user clicks on a particular row - the details of the row should be displayed in another part of the screen.
       I have used hotspots and done this - but I do not want all my entries underlined.

    Hi Atish,
    Is there any other way to trigger the single click event in the ALV grid display for a particular row ? I have come across an event CLICK_ROW_COL, which I think may solve the problem, however this is a protected event and whenever I try to access it , I get the error that a protected event cannot be accessed.
    Edited by: Aditya  Niyogi on May 14, 2008 6:33 AM

  • Single click event in alv grid.

    Hi Experts,
    i have done will my code..everything is working perfectly, but having an issue..pls help me...
    in my output screen i have 2 check-boxes,when i select both of them i shuld get a message saying select only one..this is done when am using double click. Is single click possible in alv-grid...
    please help me.
    thanks.
    anusha

    Hi Anusha,
    Did you Try by using get_selected_rows(Method)?
    If the selected rows are 2 display a message such that 'Select only One record'.
    data t_roid type lvc_t_roid.
    CALL METHOD r_grid->get_selected_rows
            IMPORTING
              et_row_no = t_roid.
    READ TABLE t_roid INDEX 1 TRANSPORTING NO FIELDS."to know how many No.Of records selected
    if sy-tfill > 1.
    Message 'Please Select only one record' type 'I'.
    Exit.
    endif.

  • Handle single click event in ALV OOPS

    Hi,
    I have to display 2 ALV grid...one above the other.
    Top ALV will contain Header info and bottom ALV witll display line item.
    I am use ALV OOPS.
    Now when user will click on the top ALV ...bottom ALV should show corresponding data.
    I don't have to use HOTSPOT or Double click event.
    How can I handle single click event.
    Please guide me..thanks in advance
    Regards,
    Prasoon

    hi,
                    for this in ALV OOPS take <b>2 custom containers( cl_gui_custom_container)</b>in the same screen and on the 1st container display the header data<b>(use set_tale_for_first_display method of class cl_gui_alv_grid)</b>.
                   On the 2nd screen item data for  this  use<b> EVENT</b> handling(you want <b>single click</b>). use<b> hotspot_click</b> or <b>button_click </b>events. 
    for this you have to register the events.   the code for that.
    <b>CLASS lcl_event_handler DEFINITION .</b>
    PUBLIC SECTION .
    METHODS:
    *--Hotspot click control
    handle_hotspot_click
    FOR EVENT hotspot_click OF cl_gui_alv_grid
    IMPORTING e_row_id e_column_id es_row_no ,
    *--To control button clicks
    handle_button_click
    FOR EVENT button_click OF cl_gui_alv_grid
    IMPORTING e_oject e_ucomm .
    PRIVATE SECTION.
    ENDCLASS.
    <b>CLASS lcl_event_handlerIMPLEMENTATION .</b>
    *--Handle Hotspot Click
    METHOD handle_hotspot_click .
    PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
    ENDMETHOD .
    METHOD handle_button_click .
    PERFORM handle_button_click USING e_object e_ucomm .
    ENDMETHOD .
    ENDCLASS .
    DATA gr_event_handler TYPE REF TO lcl_event_handler .
    <b>*--Creating an instance for the event handler</b>
    CREATE OBJECT gr_event_handler.
    <b>*--Registering handler methods to handle ALV Grid events</b>
    SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid .
    SET HANDLER gr_event_handler->handle_button_click FOR gr_alvgrid .
    do n't forget to use<b> refresh_table_display
    </b> other wise only the record which you first you clicked will display in the 2nd container.
    <b>Reward points for useful Answers</b>

  • Click Event on ALV using cl_gui_alv_grid (DYNPRO)

    How can I implement a listener for a click on ALV.
    If I click on my ALV grid, for example PBA should be triggered. Is that possible?
    Now it seems that nothing happens when I click on ALV.
    Can anyone help?

    Hi Ezachiael,
    you dont have to trigger event DOUBLE_CLICK, it will be triggered, in case of double click :-).
    You have to implent event handling class and event handler method - It is quite simple.
    Check out this [Reference on SDN|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907].
    Regards
    REA

  • On click event on alv web dynpro.

    I've inserted this code in the WDDOINIT method:
    DATA: l_ref_INTERFACECONTROLLER TYPE REF TO  IWCI_SALV_WD_TABLE .
    l_ref_INTERFACECONTROLLER =   wd_This->wd_CpIfc_Alv( ).
    DATA:
        l_VALUE type ref to Cl_Salv_Wd_Config_Table.
        l_VALUE = l_ref_INTERFACECONTROLLER->Get_Model( ).
    Display button in column subty
      lr_column = l_value->if_salv_wd_column_settings~get_column( 'SUBTY' ).
      CREATE OBJECT lr_button.
      lr_button->set_text_fieldname( 'SUBTY' ).
      lr_column->set_cell_editor( lr_button ).
    Display link in column connid
      lr_column = l_value->if_salv_wd_column_settings~get_column( 'SUBTY' ).
      CREATE OBJECT lr_link.
      lr_link->set_text_fieldname( 'SUBTY' ).
      lr_column->set_cell_editor( lr_link ).
    When I test the WD the dump occurs in this method:
    method ensure_active_component.
      if if_wd_component_usage~has_active_component( ) = abap_false.
      Active component must exist when ...
    >>>>>>>>>>>>>    raise exception type cx_wdr_rt_exception
                exporting
                  textid = cx_wdr_rt_exception=>no_active_component_found
                  msgv1  = me->name.
      endif.
    endmethod.
    Why?

    Hello,
    I am not too sure for your requirement, but what I could understood is "You have created an ALV table of buttons and have assigned with same onaction method, once cliked on any of the button, you want to figure out which button has been clicked?" If this is the casse then there is a very easy way to find out where the click has taken place, use the code below in the on action method of the button in  the alv table.
    data: lo_context_element type ref to IF_WD_CONTEXT_ELEMENT,
              lv_clicked_row       type int4.
    check wdevent is bound.
    lo_context_element =  wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
    check lo_context_element is bound.
    lv_clicked_row = lo_context_element->get_index( ).
    Once this is executed, lv_clicked_row would contain the index of the table row where the user have clicked, this value can be further used for business logic derivation purpose.
    Please let me know if this does not help!
    Thanks & Regards
    Abir Chakraborty

  • Methods for adding DBL click event in ALV

    Methods for adding DBL click event in ALV

    Hi Jagrut,
      If you are using CL_GUI_ALV_GRID class to display ALV report and want to add
      double clicking functionality to ALV need to handle event DOUBLE_CLICK
      in your local class.
      See the below code how you define it.
    *===============================================================
    * LOCAL CLASSES: Definition
    *===============================================================
    CLASS LCL_EVENT_RECEIVER DEFINITION.
      PUBLIC SECTION.
    * § 2. Define a method for each print event you need.
        METHODS:
        TOP_OF_PAGE FOR EVENT TOP_OF_PAGE
                             OF CL_GUI_ALV_GRID
                             IMPORTING E_DYNDOC_ID,
        DOUBLE_CLICK FOR EVENT DOUBLE_CLICK
                             OF CL_GUI_ALV_GRID
                             importing E_ROW.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    *===============================================================
    * LOCAL CLASSES: Implementation
    *===============================================================
    * class c_event_receiver (Implementation)
    CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
      METHOD TOP_OF_PAGE.
    * Top-of-page event
        PERFORM EVENT_TOP_OF_PAGE USING G_DYNDOC_ID.
      ENDMETHOD.                            "top_of_page
      METHOD DOUBLE_CLICK.
    * Top-of-page event
        PERFORM list using e_row.
      ENDMETHOD.                            "DOUBLE_CLICK
      You also need to register the events.
      And also check the program BCALV_GRID_VERIFY.
    Hope this will help you.
    Thanks&Regards,
    Siri.

  • Short dump while on double click event in ALV

    Hi ,
    I have created a ALV screen to display the customer number and NAme ,my requirement is that when i click on the Key field i.e. Customer number it should call the transaction xd03 for that  I have written the following code
    gs_layout-box_fieldname = 'SEL'.
    gs_layout-colwidth_optimize = 'X'.
    gd_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program       = gd_repid
       i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
        is_layout                = gs_layout
         it_fieldcat              = fieldcatalog[]
         i_callback_pf_status_set = 'PF_STATUS'
        i_callback_user_command  = 'USER_COMMAND'
      TABLES
        t_outtab                 = t_itab
      EXCEPTIONS
        program_error            = 1
        OTHERS                   = 2.
    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 user_command USING r_ucomm LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
        WHEN '&IC1'.
          IF rs_selfield-fieldname = 'KUNNR'.
            READ TABLE t_itab INTO w_itab
            WITH KEY kunnr = rs_selfield-value.
            IF sy-subrc = 0.
              SET PARAMETER ID 'KUN' FIELD rs_selfield-value.
              CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
            ENDIF.
          ENDIF.
          CLEAR r_ucomm.
      ENDCASE.
    ENDFORM.                    "user_command
    FORM pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'STANDARD1'.
    ENDFORM.                    "pf_status
    Problem is when i double click on the Customer No field on the ALV ouput i Am getting a Short dump.. "MOVE_TO_LIT_NOTALLOWED_NODATA"..
    How should i overcome this runtime error....
    Thanks in advance,
    Nishant

    >
    Abhii wrote:
    > There was a problem in the SET PARAMETER ID statement.
    > Nishant, Make the code changes I have suggested, you will get the output.
    Either you possess telepathic skills or you are omniscient.
    Before asserting your solution on someone be sure what exactly is the problem. If you check the OP's code, CALL TRANSACTION will be called only when the READ TABLE is successful.
    So how does your solution add benefit to the existing one.
    BR,
    Suhas

  • Problem in Double click event for ALV.

    Hi experts ,
    My scenario is one ALV is displayed in First screen and after double click  on particular column second screen is displayed with the other ALV.
    I have created 2 custom containers.
    My problem is that for the first double click every thing is fine,then i come back to first screen from second screen when i double click on different item the previous item is displayed which was for the first double click .
    I debugg the program ,  passing of data to the internal table is fine.
    Help me in the problem
    Thanks
    Aisurya

    Hi,
    You have to use refresh_table_dispaly  method to update the values. else it will display the same.
    try this logic
    if  cus_cont is initial.
    o_grid->set_table_for_first_display.
    else.
    o_grid->refresh_table_display.
    endif.,
    check BCALV_GRID_03 standard program for reference.
    hope this helps u.,
    Thanks & Regards,
    Kiran

  • Double Click Event In ALV Tree

    Hello guys,
    There is a requirement that when I double click on an item in ALV tree it takes me to a standard transaction code.
    Can anyone suggest me how to proceed on this.
    Thanks in Advance.
    Regards,
    Abhinav

    Hi,
    Refer:
    Get cursor field in ALV Tree
    Hope this helps you.
    Regards,
    Tarun

  • Click events in ALV

    Hai Friends,
    In my ALV report i have two radio buttons as 'A' and 'B' by default 'A' is clicked. when i execute the report first the report of 'A' will be displayed and when i click the 'Back' button i want the report of the radio button 'B' to be displayed. how can i do this. this is classical ALV.
    Thanks.

    Hi,
    Assign the two radiobuttons to different groups.Use the code snippet given below...
    data fl_flag type i.
    AT Selection-screen output.
    if fl_flag is initial.
      loop at screen.
        if screen-name CS 'RAD2'.
           screen-active = 0.
           modify screen.
        endif.
      endloop.
    else.
      loop at screen.
        if screen-name CS 'RAD1'.
           screen-active = 0.
           modify screen.
        endif.
      endloop.
    endif.
    Start-of-selection.
      if fl_flag is initial.      " this if statement is not mandatory you can just write fl_flag = 2. if you want to
    "                                remove if condition
        fl_flag = 1.
      else.
        clear fl_flag.
      endif.
    You can also give the group foridentifying the radiobutton for invisible action.
    Regards
    Edited by: Richa Tripathi on Apr 17, 2009 7:35 AM

Maybe you are looking for