ALV: Right Button Click and Context Menu

Hi Experts,
I have to implement an ALV which should act on a right button click and show a context menu.
Is this possible? I found only events for "on_double_click" or "on_link_click" and is it possible to show a context menu?
Thanks in advanced.
Best regards,
Markus

Hello Markus
The relevant events are:
CONTEXT_MENU_REQUEST
USER_COMMAND
Have a look at my sample report ZUS_SDN_ALV_CONTEXT_MENU_1.
*& Report  ZUS_SDN_ALV_CONTEXT_MENU_1
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="910750"></a>
*& Thread: ALV: Right Button Click and Context Menu
*& Flow logic of screen 100 (no screen elements; ok_code = GD_OKCODE)
*&    PROCESS BEFORE OUTPUT.
*&      MODULE STATUS_0100.
*&    PROCESS AFTER INPUT.
*&      MODULE USER_COMMAND_0100.
REPORT  zus_sdn_alv_context_menu_1.
DATA:
  gd_okcode        TYPE ui_func,
  go_docking       TYPE REF TO cl_gui_docking_container,
  go_splitter      TYPE REF TO cl_gui_splitter_container,
  go_cell_top      TYPE REF TO cl_gui_container,
  go_cell_bottom   TYPE REF TO cl_gui_container,
  go_grid1         TYPE REF TO cl_gui_alv_grid,
  go_grid2         TYPE REF TO cl_gui_alv_grid,
  gs_layout        TYPE lvc_s_layo.
DATA:
  gt_knb1          TYPE STANDARD TABLE OF knb1,
  gt_knvv          TYPE STANDARD TABLE OF knvv.
*       CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
        IMPORTING
          e_row
          e_column
          es_row_no
          sender,
      handle_context_menu_request FOR EVENT context_menu_request
                                                 OF cl_gui_alv_grid
        IMPORTING
          e_object
          sender,
      handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
        IMPORTING
          e_ucomm
          sender.
ENDCLASS.                    "lcl_eventhandler DEFINITION
*       CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
  METHOD handle_double_click.
*   define local data
    DATA:
      ls_knb1      TYPE knb1.
    CHECK ( sender = go_grid1 ).
    READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
    CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
    CALL METHOD go_grid1->set_current_cell_via_id
      EXPORTING
*        IS_ROW_ID    =
*        IS_COLUMN_ID =
        is_row_no    = es_row_no.
*   Triggers PAI of the dynpro with the specified ok-code
    CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
  ENDMETHOD.                    "handle_double_click
  METHOD handle_context_menu_request.
*   define local data
    DATA: lt_fcodes    TYPE ui_funcattr,
          ls_fcode     TYPE uiattentry,
          ls_func      TYPE ui_func,
          lt_func      TYPE ui_functions.
    "   Inactivate all standard functions
    CALL METHOD e_object->get_functions
      IMPORTING
        fcodes = lt_fcodes.
    LOOP AT lt_fcodes INTO ls_fcode.
      ls_func = ls_fcode-fcode.
      APPEND ls_func TO lt_func.
    ENDLOOP.
    e_object->disable_functions( lt_func ).
"   Add new functions
    e_object->add_separator( ).
    CALL METHOD e_object->add_function
      EXPORTING
        fcode = 'XD03'
        text  = 'Call Transaction'.
    CALL METHOD e_object->add_function
      EXPORTING
        fcode = 'DETAILS'
        text  = 'Display Details'.
  ENDMETHOD.                    "handle_context_menu_request
  METHOD handle_user_command.
*   define local data
    DATA:
      ls_knb1   TYPE knb1,
      ls_row    TYPE lvc_s_row,
      ls_col    TYPE lvc_s_col.
    "   NOTE: in case of CL_GUI_ALV_GRID the functions of a context menu
    "         are handled in method USER_COMMAND.
    CHECK ( e_ucomm = 'XD03'      OR
            e_ucomm = 'DETAILS' ).
    CALL METHOD sender->get_current_cell
      IMPORTING
        es_row_id = ls_row
        es_col_id = ls_col.
    CASE e_ucomm.
      WHEN 'XD03'.
        READ TABLE gt_knb1 INTO ls_knb1 INDEX ls_row-index.
        SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
        SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
        CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
      WHEN 'DETAILS'.
  "       NOTE: only for the sake of simplicity the event handler method
        "             is called
        CALL METHOD lcl_eventhandler=>handle_double_click
          EXPORTING
            e_row  = ls_row
            sender = go_grid1.
      WHEN OTHERS.
    ENDCASE.
  ENDMETHOD.                    "handle_user_command
ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
  SELECT        * FROM  knb1 INTO TABLE gt_knb1
         WHERE  bukrs  = '1000'.
* Create docking container
  CREATE OBJECT go_docking
    EXPORTING
      parent                      = cl_gui_container=>screen0
      ratio                       = 90
    EXCEPTIONS
      OTHERS                      = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Create splitter container
  CREATE OBJECT go_splitter
    EXPORTING
      parent            = go_docking
      rows              = 2
      columns           = 1
*      NO_AUTODEF_PROGID_DYNNR =
*      NAME              =
    EXCEPTIONS
      cntl_error        = 1
      cntl_system_error = 2
      OTHERS            = 3.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Get cell container
  CALL METHOD go_splitter->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = go_cell_top.
  CALL METHOD go_splitter->get_container
    EXPORTING
      row       = 2
      column    = 1
    RECEIVING
      container = go_cell_bottom.
* Create ALV grids
  CREATE OBJECT go_grid1
    EXPORTING
      i_parent          = go_cell_top
    EXCEPTIONS
      OTHERS            = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Set event handler
  SET HANDLER:
    lcl_eventhandler=>handle_double_click         FOR go_grid1,
    lcl_eventhandler=>handle_context_menu_request FOR go_grid1,
    lcl_eventhandler=>handle_user_command         FOR go_grid1.
  CREATE OBJECT go_grid2
    EXPORTING
      i_parent          = go_cell_bottom
    EXCEPTIONS
      OTHERS            = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Display data
  gs_layout-grid_title = 'Customers'.
  CALL METHOD go_grid1->set_table_for_first_display
    EXPORTING
      i_structure_name = 'KNB1'
      is_layout        = gs_layout
    CHANGING
      it_outtab        = gt_knb1
    EXCEPTIONS
      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.
  gs_layout-grid_title = 'Customers Details (Sales Areas)'.
  CALL METHOD go_grid2->set_table_for_first_display
    EXPORTING
      i_structure_name = 'KNVV'
      is_layout        = gs_layout
    CHANGING
      it_outtab        = gt_knvv  " empty !!!
    EXCEPTIONS
      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.
* Link the docking container to the target dynpro
  CALL METHOD go_docking->link
    EXPORTING
      repid                       = syst-repid
      dynnr                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      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.
* NOTE: dynpro does not contain any elements
  CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*PROCESS BEFORE OUTPUT.
*  MODULE STATUS_0100.
*PROCESS AFTER INPUT.
*  MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*&      Module  STATUS_0100  OUTPUT
*       text
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
*  SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
  CALL METHOD go_grid2->refresh_table_display
*    EXPORTING
*      IS_STABLE      =
*      I_SOFT_REFRESH =
    EXCEPTIONS
      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.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&      Module  USER_COMMAND_0100  INPUT
*       text
MODULE user_command_0100 INPUT.
  CASE gd_okcode.
    WHEN 'BACK' OR
         'END'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.
*   User has pushed button "Display Details"
    WHEN 'DETAIL'.
      PERFORM entry_show_details.
    WHEN OTHERS.
  ENDCASE.
  CLEAR: gd_okcode.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&      Form  ENTRY_SHOW_DETAILS
*       text
*  -->  p1        text
*  <--  p2        text
FORM entry_show_details .
* define local data
  DATA:
    ld_row      TYPE i,
    ls_knb1     TYPE knb1.
  CALL METHOD go_grid1->get_current_cell
    IMPORTING
      e_row = ld_row.
  READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
  CHECK ( syst-subrc = 0 ).
  SELECT        * FROM  knvv INTO TABLE gt_knvv
         WHERE  kunnr  = ls_knb1-kunnr.
ENDFORM.                    " ENTRY_SHOW_DETAILS
Regards
  Uwe

Similar Messages

  • I just installed FF4 and can't get a bookmark to open in a new tab using right-button click and selecting open in a new tab.

    actually, it's more complicated. It seems none of the right-button options work: Open, open in a new window, and open in a new tab.

    Safe Mode worked. Turned off hardware acceleration and it work until the next boot up, then it didn't work anymore. Made sure hardware acceleration was still off and then disabled all apps and it worked again. One-by-one, I enabled apps until all apps were again enabled. It worked with each app added. Everything still works and hasn't stopped working through about 5 boot-ups.

  • Disable right mouse click and IE6 galleryimg on af:objectImage

    hi,
    Could anyone tell me how I can disable right mouse click and IE6 galleryimg on af:objectImage?

    Hi Jagannath,
    Try like this.. Double click on application -> go to parameters tab, in parameters give WDDISABLEUSERPERSONALIZATION and value 'X'. It will disable user settings, you get window when right click but no user settings available.
    check this for more help...
    http://help.sap.com/saphelp_nw70/helpdata/en/7b/fb57412df8091de10000000a155106/content.htm
    Thanks,
    Kris.

  • Am I alone w/ Right Clk not bringing context menu w/ 8.2RC/PcWin for brush adjustment pin

    am I alone w/ Right Clk not bringing context menu w/ 8.2RC/PcWin for brush adjustment pin ?

    solved, it was my mouse setup... false alarm

  • How to create a plugin to open a pop up on right click (using context menu) of any link on any site and display the link url in the pop up

    We are developing a Plugin with the specific purpose to display the URL to which any link redirect to on any website.
    This URL should appear in the pop up when the user right clicks and selects the "show URL" option in the context menu.
    Can some one please help us either to find such plugin (except firebug) or guide us how to develop such a plugin.

    Look for related articles here: <br />
    http://developer.mozilla.org/en/

  • Context Menu (or right button click) does not appear menu-window

    The context menu does not appear in some browser sections.
    If I run browser in safe mode it works without problem.
    I've tried to reinstall firefox, after uninstall I also manualy deleted all rest hidden and visible folders - did not help.
    Also I tried restore to default mode - did not help.
    Here I put screenshoot.
    Regards.
    //sorry for my eng

    Yes, it helped. Thank you very much!
    Kind regards.

  • Right-click finder context menu no longer works

    When I bring up the context menu on any file/folder in my finder or desktop, none of the actions work - such as "Move to Trash", "Get Info", "Duplicate". In debugging I removed MagicPrefs, thinking it might issues with the mouse.
    It works if I used shortcut keys, or drag files to the trash.
    I'm not sure what changed recently - any help would be greatly appreciated.
    -John

    I'm able to bring up the menu (by right-click or control-click), all the options are enabled (nothing grayed out) ... when I choose any of them, nothing happens. No UI error, nothing in any of the logs I looked at.
    I switched to a wire-mouse and got the same result. I used the track pad and got the same result.
    Another observation - the labels do work, I can label a file some color and then remove it.

  • Add "make unique symbol" button and context menu option

    I often want to make a variation of an existing symbol that is already positioned on the page. Unless I'm missing something, the steps are to duplicate existing symbol in the symbols palette, then replace the selected symbol instance, using the "replace symbol instance" in the Control Bar. Why not have a context menu option "make unique symbol" that automatically replaces the instance with new, unique symbol? I'd also like to see "Edit Symbol" added to the context menu. I'm hovering over the symbol, why should I have to go find the "edit symbol" button? I realize I can double-click the instance, but this does not work in all cases, such as when the direct select tool is active.
    If you've used SketchUp, you know where this idea comes from.
    Thanks,
    Ray

    No, I want to make a new, unique symbol of an existing symbol instance. If I choose "break link" from the context menu or symbols palette, the artwork is no longer a symbol and after editing, must converted to a symbol using the symbols palette. This requires several, unnecessary steps. At the very least, I'd like to see "Make new symbol" added to the context menu. If you're a SketchUp user you'll know exactly what I'm talking about. Seems incidental, but AI's method is inefficient.

  • Why no Right-Click or Context Menu over Artboards?

    A context menu in the Artboard Panel would be much faster and more natural, right?
    Is there a reason this is missing?

    Not in CS6.  But yes, completely agree, probably even more essential there, as I'm guessing most people give layers more of a workout than they do Artboards.

  • Web report - Right click for context menu

    I believe SAP switched the way (left mouse button to right one) to get web report context menu as of BW 3.5. I am looking for the official documentation for it. I could not find it in online help
    http://help.sap.com/saphelp_nw04/helpdata/en/b2/e50138fede083de10000009b38f8cf/frameset.htm
    Does anyone knows where I can find it?
    Thanks in advance.

    I'm using Firefox 4.0.1 on Ubuntu 9.10 32 bit. Every time I can reproduce this bug, I'm able to revert it by killing the Adoble Flash process:
    Example:
    $ ps ax | grep libflashplayer.so
    2072 ? Rl 0:05 /opt/firefox/plugin-container /usr/lib/flashplugin-installer/libflashplayer.so -omnijar /opt/firefox/omni.jar 32533 true plugin
    2229 pts/3 S+ 0:00 grep libflashplayer.so
    $ kill 2072
    Plugin version: Shockwave Flash 10.2 r159
    Hope this helps to find the cause.
    Regards.

  • Tab bar will not generate new tab if press+ - Links work- Right Button click 'open in new tab'

    Now working with 3.6.18 (I had v4, then v5 briefly), the tab bar 'failed' in v5 so I went back to v3.6.18, but the problem followed.
    No matter how many tabs are open I cannot get a new blank tab by clicking the "+" tab on tab bar.
    I CANNOT get a new tab by mousing over another tab, right button menu "new tab" will not work.
    I CAN select a bookmark "open in new tab" it works.
    I CAN do the same on a link, "open in new tab" it opens in a new tab.

    Didn't even know I had one, so I told it to display then went to the right hand end where a drop down menu offered "uninstall" and fired that , and again, and again, and again, the sticky little booger grinned back, but would not leave.
    Reminded me of early Windows days when Win would die and tell you, "I just lost all your work" "OK?"
    Going to look for a big hammer, it used to make me feel good to have the last FINAL word.

  • Control overlapping and context menu

    hi guys,
         I have this layout with a Panel, a Tab Container and a Datagrid. Basically the Panel is the parent of the Tab Container, and Tab Container is the parent of the Datagrid. My Datagrid has a context menu on it. But what happened was I can't get the context menu to show up because if I do right-click on the grid, the context menu from the Panel is what I'm getting, not the context menu I setup on the grid, but If I move the grid outside the panel its working good. Anyone encountered same thing? How will I surpass this overlapping?
    Best Regards!

    Hey Flex, thanks a lot! I should have known this is a bug on Flex 4 Panel right? Thanks for the tip, got it by setting the mouseEnabled=true on the Panel and on the custom Panel Skin as well.
    Best Regards!

  • Flash trapallkeys and context menu issue on Mac

    Hi
    Using Flash CS3 and AS2. There seems to be a conflict when trapping all keys and with the context menu on Mac. If I have a Flash movie with a single line of code:
    fscommand("trapallkeys", "true"); 
    When I open the resulting swf in either the standalone Flash Player or if I publish as a Mac projector, when I right-click I get the context menu appear as normal, but none of the menu items work - nothing is triggered and the menu disappears. This is even the case for "Settings..." and "About Flash Player..." items. If I open the swf in a browser or run the movie from the Flash authoring environment, then the context menu works - but of course the fscommand is not run in these circumstances.
    I've tried publishing for different Flash Player versions (down to 5!) and running in different Flash Players (a couple of version 9's and the latest version 10). 
    Has/can anyone get the fscommand to run AND the context menu to work together in the standalone Flash Player or the Mac projector? By the way, this only seems to be an issue on the Mac version - both work together on a Windows machine. 
    Any help at all would be greatly appreciated. 
    Thanks, Mark

    Hello Rohan,
    We had the same issues as you described and we're on NW 2004s patch 9.
    We applied the OSS note 909314 (as SAP suggested) and those two issues were resolved.
    Thanks,
    Elena.

  • Rightclick and context menu functionality in SBO 2004

    hi guys...
    how to capture the right click event and the context menu event. I have seen the right click example in the SBO 2005 examples but how to get that functionality in SBO 2004, there r no SAPbouiCOM.ContextMenuInfo and SBO_Application.RightClickEvent
    thanx in advance..
    regards,
    Vasu..

    Hi,
    I don't think you can achieve this in the 2004 version as it was an entirely new feature in the 2005A SDK.
    Regards,
    Owen

  • Tree Control  and context menu

    Hello,
    I created a tree with a menu. But the menu is not displayed on right click of a node .... Well I can miss something...
    Anybody have an idea for help me ?
    Best regards

    Hi Aurélien,
    This feature is not yet supported. Nonetheless, starting with SP13 you will be able to connect context menus to any ui element in the same way as it is the case in 7.10 with the limitation that context menu inheritance between ui elements along the ui element hierarchy not supported in SP13.
    Best regards,
    Thomas

Maybe you are looking for

  • Error when running Adobe form?

    Hi all, When i ran my Adobe Form appl, I got this error. What to be configured?Plz help me <b>Error:</b> com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Error during call to AdobeDocumentServer: Processing exception during a "UsageRights

  • Using xsl:import and trying to access a variable defined in another xsl

    Hi I am having a a.xsl file with contents liek this : <xsl:variable name="PersonId" select="'1910'"/> inside b.xsl i am importing a.xsl like <xsl:import href="a.xsl"/> <xsl:value-of select="$PersonId"/> This is working fine when i am testing it stand

  • Capturing with a converter

    I set up my capture so its set for dvNTSC dv converter, and am running a signal through my converter and connecting the output fire wire to final cut express. It's not reading the signal. The converter is accurate and adjusted properly (i know this,

  • Location of Oracle 11g R1 kits?

    Hi My team needs to do some testing with Oracle Database 11g R1 (we can't go to R2 just yet).  I can't seem to find the kits.  Where should I be looking? Thanks tl

  • Help with regions

    hi all. i have 3 html regions on page. i used 1st region to place some drop down combos. next 2 regions are for reports depending on the values of the combos. now the problem is layout. i have set column value for combo region as 1. for first report