Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Double click event problem

Former Member
0 Kudos

**********************************************************************
*       CLASS cl_event_receiver DEFINITION      Handles Double Click
***********************************************************************
CLASS CL_EVENT_RECEIVER DEFINITION.
  PUBLIC SECTION.
    METHODS HANDLE_DOUBLE_CLICK
      FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
      IMPORTING E_ROW E_COLUMN.
  PRIVATE SECTION.
ENDCLASS.

***********************************************************************
*       CLASS CL_EVENT_RECEIVER IMPLEMENTATION    Handles Double Click
***********************************************************************
CLASS CL_EVENT_RECEIVER IMPLEMENTATION.
  METHOD HANDLE_DOUBLE_CLICK.
    PERFORM DRILL_DOWN USING E_ROW-INDEX.
  ENDMETHOD.
ENDCLASS.

FORM drill_down USING index.

  CLEAR wa_output.
  TABLES: mepo_topline.
  READ TABLE it_output INDEX index INTO wa_output.
  IF sy-subrc = 0.
    mepo_topline-ebeln = wa_output-ebeln.
    SET PARAMETER ID 'BES' FIELD mepo_topline-ebeln.
    CALL TRANSACTION 'ME23N'." AND SKIP FIRST SCREEN.

  ENDIF.

ENDFORM.                    "DRILL_DOWN

This is my code for double click event on lines of ALV report. Its working fine with exception, that is.

I have subtoal the $ amount on top of each po line item. In some cases when i click on subtotal line of PO, then in index variable, system is populating the wrong index and hence it' opens a wrong PO, which is not reqruied.

In most of the cases it's working fine even with subtotal field.

Please suggest me to resolve this issue.

Thanks,

Message was edited by:

Sal Khan

11 REPLIES 11

former_member194669
Active Contributor
0 Kudos

Hi,


implementation.

double_click_200
         for event double_click
         of cl_gui_alv_grid
         importing e_row e_column es_row_no,

method double_click_200.
    v_dclick = c_y.
    move e_row to wa_dblclk_rows.
    append wa_dblclk_rows to i_dblclk_rows.
    " Check here wa_dblclk_rows-rowtype some values like T 0100 0000000001 if you double click on TOTAL row 
    " others shows it blank. using this you can control the call transaction


    endif.
    clear : v_dclick.
endmethod.                             

0 Kudos

Hi a®s,

Can you pls tell me in detail, how to fix it. what is c_y and with what field i have to check. Pls explain...

Message was edited by:

Sal Khan

0 Kudos

Hi,

Check this


FORM drill_down USING index.
types : begin of t_row_b.
        include structure lvc_s_row.     
types : end of t_row_b.

data :   wa_dblclk_rows     type t_row_b.

    move e_row to wa_dblclk_rows.
    " Check here wa_dblclk_rows-rowtype some values like T 0100 0000000001 if you double click on TOTAL row 
    " others shows it blank. using this you can control the call transaction
     
  CLEAR wa_output.
  TABLES: mepo_topline.
  READ TABLE it_output INDEX index INTO wa_output.
  IF sy-subrc = 0.
    mepo_topline-ebeln = wa_output-ebeln.
    SET PARAMETER ID 'BES' FIELD mepo_topline-ebeln.
    CALL TRANSACTION 'ME23N'." AND SKIP FIRST SCREEN.
 
  ENDIF.
 
ENDFORM.      

0 Kudos

My problem is e.g if i click on total row which is one,,,i get the index 2, and hence it's calling the PO which is at index 2 in my internal table.

Using ur check condition, i'm not understanding, how can i get the correct line index. e.g in this case, index = 1.

what is the benifit of this check condition. Do this check conidtion correct my index. As i'have the wrong index... I am still confused in writting the check condition

Pls help..

Message was edited by:

Sal Khan

0 Kudos

Hi,

If the user clicks on total line then you need to give information message saying that "click on the non total line " like that . The check is for you can identify the user clicks on a total line or non total line.

0 Kudos

so you mean it's not possible to go to that PO, if user double clicks on total field...

???

Yes, if it's not possible i'll give info message, but may be this is not acceptable.

former_member191735
Active Contributor
0 Kudos

I would suggest you to use Hotspot on PO number. This handles properly.

0 Kudos

How to use hotspot.

Thanks,

0 Kudos

Hi..

For Hotspot check the code below. Hope this helps...


*&------------------------------------------------------*
*& Report displaying an ALV GRID CONTROL which responds *
*& to HOTSPOT click event                               *
*&------------------------------------------------------*

REPORT  ZZ_ALV_GRID_RESPONDING_HOTSPOT_CLICK .

TABLES : BKPF .
DATA : I_BKPF TYPE STANDARD TABLE OF BKPF WITH HEADER LINE .
DATA : MOK_CODE LIKE SY-UCOMM .
DATA : OK_CODE LIKE SY-UCOMM .


DATA : MM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER .
DATA : MM_ALVGRID  TYPE REF TO CL_GUI_ALV_GRID .

DATA : CT_FIELDCAT TYPE STANDARD TABLE OF LVC_S_FCAT   .
DATA : WA_FIELDCAT LIKE LVC_S_FCAT   .


*------------------------------------------------------*
*       CLASS RESPOND_EVENTS DEFINITION
*------------------------------------------------------*
*------------------------------------------------------*
CLASS RESPOND_EVENTS DEFINITION  .
  PUBLIC SECTION .
    METHODS : RESPOND_HOTSPOT_CLICK FOR EVENT 
             HOTSPOT_CLICK OF
             CL_GUI_ALV_GRID IMPORTING  E_ROW_ID
                                        E_COLUMN_ID
                                        ES_ROW_NO.
ENDCLASS .                    "RESPOND_EVENTS DEFINITION

*------------------------------------------------------*
*     CLASS RESPOND_EVENTS IMPLEMENTATION
*------------------------------------------------------*
*------------------------------------------------------*
CLASS RESPOND_EVENTS IMPLEMENTATION .

  METHOD RESPOND_HOTSPOT_CLICK  .
 
    CLEAR BKPF .
    READ TABLE I_BKPF INDEX  E_ROW_ID INTO BKPF .
    IF SY-SUBRC EQ 0 .
      SET PARAMETER ID 'BLN' FIELD BKPF-BELNR .
      SET PARAMETER ID 'BUK' FIELD BKPF-BUKRS .
      SET PARAMETER ID 'GJR' FIELD BKPF-GJAHR .
      CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN .

    ENDIF .

  ENDMETHOD .            "RESPOND_HOTSPOT_CLICK
ENDCLASS .               "RESPOND_EVENTS IMPLEMENTATION

DATA : I_RESPOND_EVENTS TYPE REF TO RESPOND_EVENTS  .

*=====================================================
* SELECTION SCREEN - ( DEFAULT ) 
*=====================================================
SELECT-OPTIONS : S_BELNR FOR I_BKPF-BELNR  OBLIGATORY.

*=====================================================
* START OF SELECTION
*=====================================================
START-OF-SELECTION .

  SELECT * FROM BKPF 
  INTO CORRESPONDING FIELDS OF TABLE I_BKPF
  WHERE BELNR IN S_BELNR .

*======================================================
* END-OF-SELECTION  .
*======================================================
END-OF-SELECTION  .
  CALL SCREEN 100 .
* ------------------------------------------------------
* The screen 100 has a custom control named 'MCONTAINER'
* and a command button with function code 'QUIT' . 
* Of course has an element called OK_CODE like sy-ucomm .
* The flow logic of the screen has in the output section
* the module PREPARE_OUTPUT , 
* and in the input section the module USER_COMMAND_0100 .
* ------------------------------------------------------

*&-----------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&-----------------------------------------------------*
*  
*------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
  CLEAR : MOK_CODE .
  MOK_CODE = OK_CODE .
  CLEAR : OK_CODE .
  CASE MOK_CODE .
    WHEN 'QUIT' .
      LEAVE TO SCREEN 0 .
  ENDCASE .
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&-----------------------------------------------------*
*&      Module  OUTPUT  OUTPUT
*&-----------------------------------------------------*
*       text
*------------------------------------------------------*
MODULE PREPARE_OUTPUT OUTPUT .
  IF MM_CONTAINER  IS INITIAL .
    CREATE OBJECT MM_CONTAINER 
    EXPORTING CONTAINER_NAME = 'MCONTAINER' .

    CREATE OBJECT MM_ALVGRID 
    EXPORTING I_PARENT = MM_CONTAINER .

    PERFORM CATALOG_CREATION .

    PERFORM SHOW_DATA .

    CREATE OBJECT I_RESPOND_EVENTS .
    SET HANDLER I_RESPOND_EVENTS->RESPOND_HOTSPOT_CLICK 
    FOR MM_ALVGRID .

  ENDIF .
ENDMODULE.                 " OUTPUT  OUTPUT
*&----------------------------------------------------*
*&      Form  CATALOG_CREATION
*&----------------------------------------------------*
*
FORM CATALOG_CREATION .

  call function 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name = 'BKPF'
    CHANGING
      ct_fieldcat      = Ct_fieldcat.


  LOOP AT Ct_fieldcat INTO WA_fieldcat.
    IF  ( WA_FIELDCAT-FIELDNAME NE 'BUKRS' )
    AND ( WA_FIELDCAT-FIELDNAME NE 'BELNR' )
    AND ( WA_FIELDCAT-FIELDNAME NE 'GJAHR' ) .
      WA_FIELDCAT-HOTSPOT = 'X' .
      MODIFY Ct_fieldcat FROM WA_fieldcat.
    ENDIF .
  ENDLOOP.

  DELETE Ct_fieldcat  WHERE HOTSPOT = 'X' .

  LOOP AT Ct_fieldcat INTO WA_fieldcat.
    IF  WA_FIELDCAT-FIELDNAME EQ 'BELNR'   .
      WA_FIELDCAT-HOTSPOT = 'X' .
      MODIFY Ct_fieldcat FROM WA_fieldcat.
    ENDIF .

  ENDLOOP.


ENDFORM.                    " CATALOG_CREATION
*&--------------------------------------------------*
*&      Form  SHOW_DATA
*&--------------------------------------------------*
FORM SHOW_DATA .
  CALL METHOD MM_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
    CHANGING
      IT_OUTTAB       = I_BKPF[]
      IT_FIELDCATALOG = Ct_fieldcat[].
ENDFORM.                    " SHOW_DATA

regards,

chaithanya.

0 Kudos

I have implemented the hotspot but same problem. If i click on the total (I mean in the first line where i'm displaying toals of PO line item), then its showing some other PO in ME23N transaction. Its not capturing the proper line index.

Any suggestion....

Thanks

former_member191735
Active Contributor
0 Kudos

Use hotspot only on po number. If you do so, there will be no hotspot on other fields.

Example:

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = str_report

CHANGING

ct_fieldcat = p_it_fieldcat

EXCEPTIONS

inconsistent_interface = 1

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

READ TABLE p_it_fieldcat ASSIGNING <fieldcat>

WITH KEY fieldname = 'VBELN'.

<fieldcat>-hotspot = c_on.

Str_report will have the value of structure created in se11 for fieldcatalog.

CLASS lcl_event_receiver DEFINITION DEFERRED. "for screen 100

DATA: event_receiver TYPE REF TO lcl_event_receiver.

Method

----


  • CLASS lcl_event_receiver DEFINITION

----


CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS:

handle_hotspot_click

FOR EVENT hotspot_click OF cl_gui_alv_grid

IMPORTING e_row_id e_column_id es_row_no.

ENDCLASS. "

implementaion

METHOD handle_hotspot_click.

IF e_column_id-fieldname = 'VBELN'.

IF e_row_id CO c_int.

READ TABLE it_final INTO wa_final INDEX e_row_id.

IF sy-subrc = 0.

SET PARAMETER ID 'AUN' FIELD wa_final-vbeln.

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

ENDIF.

ENDIF.

ENDIF.

ENDMETHOD. "handle_double_click

You need to give this after the Method first display

CREATE OBJECT event_receiver.

SET HANDLER

event_receiver->handle_hotspot_click FOR gc_grid.