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

Click Event

Hi, Can I use the event "click" ?? Do it exist ?

I need use in an ALV the two events, "click" and "double click". I only know the second event.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2007 at 12:19 PM

    yes - u can try this eent - CLICK_ROW_COL of CL_CUI_ALV_GRID.

    Its a protected method, so in your code you will have to create a local class inheriting CL_GUI_ALV_GRID and then u can handle this CLICK event also.

    You can check RIGHT_CLICK also. Otherwise for selected columns you can turn HOTSPOT on and when you click on them the event HOTSPOT_CLICK will be fired.

    Lot of options - isnt it ?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2007 at 12:13 PM

    Hi ,

    Here I'm sending 2 programs with user command on grid and list.

    along with interaction and commentory boxes and all.

    • separate box ****************

    TABLES: KNA1,VBAK,VBAP.

    TYPE-POOLS: SLIS.

    SELECT-OPTIONS: CUST FOR KNA1-KUNNR.

    DATA: BEGIN OF ITAB OCCURS 0,

    KUNNR LIKE KNA1-KUNNR,

    NAME LIKE KNA1-NAME1,

    LAND1 LIKE KNA1-LAND1,

    END OF ITAB.

    DATA: BEGIN OF JTAB OCCURS 0,

    VBELN LIKE VBAK-VBELN,

    NETWR LIKE VBAK-NETWR,

    END OF JTAB.

    DATA: BEGIN OF KTAB OCCURS 0,

    POSNR LIKE VBAP-POSNR,

    MATNR LIKE VBAP-MATNR,

    END OF KTAB.

    DATA: REPID LIKE SY-REPID,

    *INTERNAL TABLE AND STRUCTURE.

    *SLIS_T_FIELDCAT_ALV IS AN INTERNAL TABLE.

    *SLIS_FIELDCAT_ALV IS AN STRUCTURE.

    F_KNA11 TYPE SLIS_T_FIELDCAT_ALV,

    F_KNA1 TYPE SLIS_FIELDCAT_ALV,

    F_VBAK1 TYPE SLIS_T_FIELDCAT_ALV,

    F_VBAK TYPE SLIS_FIELDCAT_ALV,

    F_VBAP1 TYPE SLIS_T_FIELDCAT_ALV,

    F_VBAP TYPE SLIS_FIELDCAT_ALV,

    I_EVENTS TYPE SLIS_T_EVENT,

    S_EVENTS TYPE SLIS_ALV_EVENT.

    PERFORM GET-VAL.

    REPID = SY-REPID.

    SELECT KUNNR NAME1 LAND1 FROM KNA1 INTO TABLE ITAB WHERE KUNNR IN

    CUST

    .

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = REPID

    IT_FIELDCAT = F_KNA11

    IT_EVENTS = I_EVENTS

    TABLES

    T_OUTTAB = ITAB.

    • GET VAL

    FORM GET-VAL.

    F_KNA1-FIELDNAME = 'KUNNR'.

    F_KNA1-REF_TABNAME = 'KNA1'.

    F_KNA1-REF_FIELDNAME = 'KUNNR'.

    APPEND F_KNA1 TO F_KNA11.

    F_KNA1-FIELDNAME = 'NAME'.

    F_KNA1-REF_TABNAME = 'KNA1'.

    F_KNA1-REF_FIELDNAME = 'NAME1'.

    APPEND F_KNA1 TO F_KNA11.

    F_KNA1-FIELDNAME = 'LAND1'.

    F_KNA1-REF_TABNAME = 'KNA1'.

    F_KNA1-REF_FIELDNAME = 'LAND1'.

    APPEND F_KNA1 TO F_KNA11.

    F_VBAK-FIELDNAME = 'VBELN'.

    F_VBAK-REF_TABNAME = 'VBAK'.

    F_VBAK-REF_FIELDNAME = 'VBELN'.

    APPEND F_VBAK TO F_VBAK1.

    F_VBAK-FIELDNAME = 'NETWR'.

    F_VBAK-REF_TABNAME = 'VBAK'.

    F_VBAK-REF_FIELDNAME = 'NETWR'.

    F_VBAK-DO_SUM = 'X'.

    APPEND F_VBAK TO F_VBAK1.

    F_VBAP-FIELDNAME = 'POSNR'.

    F_VBAP-REF_TABNAME = 'VBAP'.

    F_VBAP-REF_FIELDNAME = 'POSNR'.

    APPEND F_VBAP TO F_VBAP1.

    F_VBAP-FIELDNAME = 'MATNR'.

    F_VBAP-REF_TABNAME = 'VBAP'.

    F_VBAP-REF_FIELDNAME = 'MATNR'.

    APPEND F_VBAP TO F_VBAP1.

    S_EVENTS-NAME = 'USER_COMMAND'.

    S_EVENTS-FORM = 'VAL'.

    APPEND S_EVENTS TO I_EVENTS.

    ENDFORM.

    FORM VAL USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.

    DATA: CUS(10) TYPE N,

    SALNO(10) TYPE N,

    MAT(10) TYPE C.

    • display lists

    IF SEL-FIELDNAME = 'KUNNR'.

    CUS = SEL-VALUE.

    SELECT VBELN NETWR FROM VBAK INTO TABLE JTAB WHERE KUNNR = CUS.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = REPID

    IT_FIELDCAT = F_VBAK1

    IT_EVENTS = I_EVENTS

    TABLES

    T_OUTTAB = JTAB.

    ENDIF.

    IF SEL-FIELDNAME = 'VBELN'.

    SALNO = SEL-VALUE.

    SELECT POSNR MATNR FROM VBAP INTO TABLE KTAB WHERE VBELN = SALNO.

    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

    EXPORTING

    I_TITLE = ' ITEM DETAILS'

    I_TABNAME = VBAP

    IT_FIELDCAT = F_VBAP1

    I_CALLBACK_PROGRAM = REPID

    IMPORTING

    ES_SELFIELD = SEL

    TABLES

    T_OUTTAB = KTAB.

    ENDIF.

    IF SEL-FIELDNAME = 'MATNR'.

    MAT = SEL-VALUE.

    SET PARAMETER ID 'MAT' FIELD MAT.

    CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

    ENDIF.

    ENDFORM.

    • Grid Display ***************

    TYPE-POOLS: SLIS.

    TABLES: KNA1.

    *DATA: ITAB TYPE STANDARD TABLE OF ZJKNA1 WITH HEADER LINE.

    DATA: BEGIN OF ITAB OCCURS 0,

    KUNNR TYPE KUNNR,

    NAME1 TYPE KNA1-NAME1,

    END OF ITAB.

    DATA: JTAB LIKE ITAB OCCURS 0 WITH HEADER LINE.

    DATA: IT_TOP TYPE SLIS_T_LISTHEADER.

    DATA: W_TOP TYPE SLIS_LISTHEADER.

    DATA: IT_EVENT TYPE SLIS_T_EVENT.

    DATA: W_EVENT TYPE SLIS_ALV_EVENT.

    *

    W_EVENT-NAME = 'TOP_OF_PAGE'.

    W_EVENT-FORM = 'TOPS'.

    APPEND W_EVENT TO IT_EVENT.

    *

    W_EVENT-NAME = 'USER_COMMAND'.

    W_EVENT-FORM = 'UCOM'.

    APPEND W_EVENT TO IT_EVENT.

    DATA: S_LAYOUT TYPE SLIS_LAYOUT_ALV.

    *S_LAYOUT-NO_VLINE = 'X'.

    S_LAYOUT-ZEBRA = 'X'.

    S_LAYOUT-NO_COLHEAD = ''.

    S_LAYOUT-TOTALS_ONLY = 'TL'.

    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.

    DATA: W_LISTHEADER TYPE SLIS_LISTHEADER.

    W_LISTHEADER-TYP = 'H'.

    W_LISTHEADER-KEY = 'THIS IS LIST'.

    APPEND W_LISTHEADER TO IT_LISTHEADER.

    DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

    DATA: W_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

    W_FIELDCAT-COL_POS = 1.

    W_FIELDCAT-FIELDNAME = 'KUNNR'.

    W_FIELDCAT-TABNAME = 'ITAB'.

    W_FIELDCAT-SELTEXT_M = 'CUST. NO'.

    W_FIELDCAT-HOTSPOT = 'X'.

    APPEND W_FIELDCAT TO IT_FIELDCAT.

    CLEAR W_FIELDCAT.

    W_FIELDCAT-COL_POS = 2.

    W_FIELDCAT-FIELDNAME = 'NAME1'.

    W_FIELDCAT-TABNAME = 'ITAB'.

    W_FIELDCAT-SELTEXT_M = 'CUST. NAME'.

    W_FIELDCAT-OUTPUTLEN = 30.

    APPEND W_FIELDCAT TO IT_FIELDCAT.

    CLEAR W_FIELDCAT.

    SELECT KUNNR NAME1 FROM KNA1 INTO CORRESPONDING FIELDS OF TABLE ITAB

    UP TO 50 ROWS.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = SY-REPID

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    • I_CALLBACK_TOP_OF_PAGE = W_LISTHEADER

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = 'ENJOY.BMP'

    • I_GRID_TITLE = 'THIS IS MY FIRST ALV REPORT'

    • I_GRID_SETTINGS = W_LISTHEADER

    IS_LAYOUT = S_LAYOUT

    IT_FIELDCAT = IT_FIELDCAT

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    IT_EVENTS = IT_EVENT

    • 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

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • I_HTML_HEIGHT_TOP =

    • I_HTML_HEIGHT_END =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    T_OUTTAB = 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 TOPS

    **&----


    *

    • text

    **----


    *

    • --> p1 text

    • <-- p2 text

    **----


    FORM TOPS .

    REFRESH IT_TOP.

    W_TOP-TYP = 'H'.

    *W_TOP-KEY = 'JAGAN'.

    W_TOP-INFO = 'THIS IS SAMPLE HEADER'.

    APPEND W_TOP TO IT_TOP.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = IT_TOP

    I_LOGO = 'IDLOGO1'

    • I_END_OF_LIST_GRID =

    .

    ENDFORM. " TOPS

    *

    *

    *

    *&----


    *& Form UCOM

    *&----


    • text

    *----


    • --> p1 text

    • <-- p2 text

    *----


    FORM UCOM USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.

    DATA: CUS(10) TYPE N VALUE '0000000000'.

    CUS = SEL-VALUE.

    REFRESH ITAB.

    SELECT KUNNR NAME1 FROM KNA1 INTO TABLE ITAB WHERE KUNNR = CUS.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = SY-REPID

    IT_FIELDCAT = IT_FIELDCAT

    • IT_EVENTS = IT_EVENTS

    TABLES

    T_OUTTAB = ITAB.

    ENDFORM. " UCOM

    for single click events...

    for this in ALV OOPS take 2 custom containers( cl_gui_custom_container)in the same screen and on the 1st container display the header data(use set_tale_for_first_display method of class cl_gui_alv_grid).

    On the 2nd screen item data for this use EVENT handling(you want single click). use hotspot_click or button_click events.

    for this you have to register the events. the code for that.

    CLASS lcl_event_handler DEFINITION .

    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.

    CLASS lcl_event_handlerIMPLEMENTATION .

    *--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 .

    .. ..

    *--Creating an instance for the event handler

    CREATE OBJECT gr_event_handler.

    *--Registering handler methods to handle ALV Grid events

    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 refresh_table_display

    other wise only the record which you first you clicked will display in the 2nd container.

    thanks,

    <b><REMOVED BY MODERATOR></b>

    Message was edited by:

    Velmurugan

    Message was edited by:

    Alvaro Tejada Galindo

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 21, 2007 at 01:56 PM

    Hi Óscar.

    Are you using an object oriented alv?

    Best Regards,

    -h

    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.