Application Development and Automation 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: 
Read only

on_double_click

Former Member
0 Likes
1,116

Hello friends,

nothing happens if klick on a item can you say me pls why ?

Other events are not important

Regards

ertas


report test.

class cl_gui_column_tree definition load.

class cl_gui_cfw definition load.

data tree1 type ref to cl_gui_alv_tree_simple.

DATA: BEGIN OF wa_sbook.
INCLUDE TYPE sbook.
DATA:   status,
        zeilenfarbe(4),
        zellenfarben TYPE lvc_t_scol,
        telefon TYPE scustom-telephone,
        storniert TYPE icon-id,
        symbol TYPE symbol,
      END OF wa_sbook.

data it_sbook   LIKE TABLE OF wa_sbook.


*include <icon>.

include bcalv_simple_event_receiver.



data: gt_sflight type sflight occurs 0, "Output-Table

gt_fieldcatalog type lvc_t_fcat, "Fieldcatalog

gt_sort type lvc_t_sort, "Sortiertabelle
ok_code like sy-ucomm. "OK-Code


*----------------------------------------------------------------------*
*       CLASS lcl_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*

CLASS lcl_handler DEFINITION.
  PUBLIC SECTION.
     CLASS-METHODS:
      on_double_click FOR EVENT ITEM_DOUBLE_CLICK OF cl_gui_alv_tree_simple
       IMPORTING FIELDNAME INDEX_OUTTAB GROUPLEVEL.
ENDCLASS.                    "lcl_handler DEFINITION


CLASS lcl_handler IMPLEMENTATION.
METHOD on_double_click.
    DATA: m_text(255),
          hv_row_id(10).

*    hv_row_id = es_row_no-row_id.
*    CONCATENATE hv_row_id e_column-fieldname INTO m_text
*      SEPARATED BY space.
    MESSAGE m_text TYPE 'I'.

*    READ TABLE it_sbook INTO wa_sbook INDEX es_row_no-row_id.
*    IF sy-subrc EQ 0.
      MESSAGE i888(sabapdocu) WITH wa_sbook-carrid wa_sbook-connid
        wa_sbook-fldate wa_sbook-bookid.

*    ELSE.
*      MESSAGE 'Bitte gültige Zeile wählen' TYPE 'I'.
*    ENDIF.

  ENDMETHOD.                    "on_double_click
ENDCLASS.                    "lcl_handler IMPLEMENTATION




start-of-selection.

end-of-selection.

  call screen 100.

*&---------------------------------------------------------------------*

*& Form BUILD_FIELDCATALOG

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

form build_fieldcatalog.

* get fieldcatalog

  call function 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name = 'SFLIGHT'
    CHANGING
      ct_fieldcat      = gt_fieldcatalog.

* change fieldcatalog

  data: ls_fieldcatalog type lvc_s_fcat.

  loop at gt_fieldcatalog into ls_fieldcatalog.

    case ls_fieldcatalog-fieldname.

      when 'CARRID' or 'CONNID' or 'FLDATE'.

        ls_fieldcatalog-no_out = 'X'.

        ls_fieldcatalog-key = ''.

      when 'PRICE' or 'SEATSOCC' or 'SEATSMAX' or 'PAYMENTSUM'.

        ls_fieldcatalog-do_sum = 'X'.

    endcase.

    modify gt_fieldcatalog from ls_fieldcatalog.

  endloop.

endform. " BUILD_FIELDCATALOG

*&---------------------------------------------------------------------*

*& Form BUILD_OUTTAB

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

form build_outtab.

  select * from sflight into table gt_sflight.

* up to 1 rows.

endform. " BUILD_OUTTAB

*&---------------------------------------------------------------------*

*& Form BUILD_SORT_TABLE

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

* D A S  W I C H T I G T S T E * * * * * * * * * * * * * * * * * * * * *

form build_sort_table.

  data ls_sort_wa type lvc_s_sort.

* create sort-table

  ls_sort_wa-spos = 1.

*ls_sort_wa-fieldname = 'CARRID'.
  ls_sort_wa-fieldname = 'FLDATE'.

  ls_sort_wa-up = 'X'.

  ls_sort_wa-subtot = 'X'.

  ls_sort_wa-seltext = 'Flugdatum'.

  append ls_sort_wa to gt_sort.

  ls_sort_wa-spos = 2.

*ls_sort_wa-fieldname = 'CONNID'.
  ls_sort_wa-fieldname = 'CARRID'.

  ls_sort_wa-up = 'X'.

  ls_sort_wa-subtot = 'X'.

  ls_sort_wa-seltext = 'Flugges.'.

  append ls_sort_wa to gt_sort.

  ls_sort_wa-spos = 3.

*ls_sort_wa-fieldname = 'FLDATE'.
  ls_sort_wa-fieldname = 'CONNID'.

  ls_sort_wa-up = 'X'.

  ls_sort_wa-seltext = 'Flug-Nr.'.

  append ls_sort_wa to gt_sort.

endform. " BUILD_SORT_TABLE

* D A S  W I C H T I G T S T E * * * * * * * * * * * * * * * * * * * * *

*&---------------------------------------------------------------------*

*& Module PBO OUTPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

module pbo output.

  if tree1 is initial.

    perform init_tree.

  endif.

  set pf-status 'MAIN100'.

endmodule. " PBO OUTPUT

*&---------------------------------------------------------------------*

*& Module PAI INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

module pai input.

  case ok_code.

    when 'EXIT' or 'BACK' or 'CANC'.

      perform exit_program.

    when others.

      call method cl_gui_cfw=>dispatch.

  endcase.

  clear ok_code.

endmodule. " PAI INPUT

*&---------------------------------------------------------------------*

*& Form exit_program

*&---------------------------------------------------------------------*

* free object and leave program

*----------------------------------------------------------------------*

form exit_program.

  call method tree1->free.

  leave program.

endform. " exit_program

*&---------------------------------------------------------------------*

*& Form register_events

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

form register_events.

* define the events which will be passed to the backend

  data: lt_events type cntl_simple_events,

  l_event type cntl_simple_event.

* define the events which will be passed to the backend

  l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.

  append l_event to lt_events.

  l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.

  append l_event to lt_events.

  l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.

  append l_event to lt_events.

  l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.

  append l_event to lt_events.

  l_event-eventid = cl_gui_column_tree=>eventid_header_click.

  append l_event to lt_events.

  l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.

  append l_event to lt_events.



  call method tree1->set_registered_events
    EXPORTING
      events                    = lt_events
    EXCEPTIONS
      cntl_error                = 1
      cntl_system_error         = 2
      illegal_event_combination = 3.

* set Handler  * -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> ->

  data: l_event_receiver type ref to lcl_tree_event_receiver.

  create object l_event_receiver.

  set handler l_event_receiver->on_add_hierarchy_node

  for tree1.


  data: l_event_rec type ref to lcl_handler.

  create object l_event_rec.

  set handler l_event_rec->on_double_click

  for tree1.




  SET HANDLER:
      lcl_handler=>on_double_click FOR tree1.

endform. " register_events

*&---------------------------------------------------------------------*

*& Form build_header

*&---------------------------------------------------------------------*

* build table for html_header

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

form build_comment using

pt_list_commentary type slis_t_listheader

p_logo type sdydo_value.

  data: ls_line type slis_listheader.

*

* LIST HEADING LINE: TYPE H

  clear ls_line.

  ls_line-typ = 'H'.

* LS_LINE-KEY: NOT USED FOR THIS TYPE

  ls_line-info = 'Hakans first tree'.                       "#EC NOTEXT

  append ls_line to pt_list_commentary.

* STATUS LINE: TYPE S

  clear ls_line.

  ls_line-typ = 'S'.

  ls_line-key = 'valid to'.                                 "#EC NOTEXT

  ls_line-info = 'January 29 1999'.                         "#EC NOTEXT

  append ls_line to pt_list_commentary.

  ls_line-key = 'time'.

  ls_line-info = '2.00 pm'.                                 "#EC NOTEXT

  append ls_line to pt_list_commentary.

* ACTION LINE: TYPE A

  clear ls_line.

  ls_line-typ = 'A'.

* LS_LINE-KEY: NOT USED FOR THIS TYPE

  ls_line-info = 'up-to-date data'.                         "#EC NOTEXT

  append ls_line to pt_list_commentary.

  p_logo = ''.

endform.                    "build_comment

*&---------------------------------------------------------------------*

*& Form init_tree

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM init_tree.

  perform build_fieldcatalog.

  perform build_outtab.

  perform build_sort_table.

* create container for alv-tree

  data: l_tree_container_name(30) type c,

  l_custom_container type ref to cl_gui_custom_container.

  l_tree_container_name = 'TREE1'.

  create object l_custom_container

  exporting

  container_name = l_tree_container_name

  exceptions

  cntl_error = 1

  cntl_system_error = 2

  create_error = 3

  lifetime_error = 4

  lifetime_dynpro_dynpro_link = 5.

* create tree control

  create object tree1

  exporting

  i_parent = l_custom_container

  i_node_selection_mode =

  cl_gui_column_tree=>node_sel_mode_multiple

  i_item_selection = 'X'

  i_no_html_header = 'X'

  i_no_toolbar = ''

  exceptions

  cntl_error = 1

  cntl_system_error = 2

  create_error = 3

  lifetime_error = 4

  illegal_node_selection_mode = 5

  failed = 6

  illegal_column_name = 7.

* create info-table for html-header

  data: lt_list_commentary type slis_t_listheader,

  l_logo type sdydo_value.

*perform build_comment using

*lt_list_commentary
*
*l_logo.

* repid for saving variants

  data: ls_variant type disvariant.

  ls_variant-report = sy-repid.

* register events

  perform register_events.

* create hierarchy * -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> ->

  call method tree1->set_table_for_first_display

   exporting
*
*it_list_commentary = lt_list_commentary
*
*i_logo = l_logo

*i_background_id = 'ALV_BACKGROUND'

*i_background_id = ''

  i_save = 'A'

  is_variant = ls_variant

  changing

  it_sort = gt_sort

  it_outtab = gt_sflight

  it_fieldcatalog = gt_fieldcatalog.

* expand first level

  call method tree1->expand_Tree
    EXPORTING
      i_level = 1.

* optimize column-width

  call method tree1->column_optimize
    EXPORTING
      i_start_column = tree1->c_hierarchy_column_name
      i_end_column   = tree1->c_hierarchy_column_name.



ENDFORM. " init_tree
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module USER_COMMAND_0100 input.
  case ok_code.

    when 'EXIT' or 'BACK' or 'CANC'.

      perform exit_program.

    when others.

      call method cl_gui_cfw=>dispatch.

  endcase.

  clear ok_code.


endmodule.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module STATUS_0100 output.

*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.
  if tree1 is initial.

    perform init_tree.

  endif.

  set pf-status 'MAIN100'.

endmodule.                 " STATUS_0100  OUTPUT

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,009

Hello Ilhan

You need to register the double-click event:


form register_events.
 
* define the events which will be passed to the backend
 
  data: lt_events type cntl_simple_events,
 
  l_event type cntl_simple_event.
 
* define the events which will be passed to the backend
 
  l_event-eventid = cl_gui_column_tree=>EVENTID_NODE_DOUBLE_CLICK.
 
  append l_event to lt_events.
...

Regards

Uwe

Hello Ilhan

You need to register the double-click event:


form register_events.
 
* define the events which will be passed to the backend
 
  data: lt_events type cntl_simple_events,
 
  l_event type cntl_simple_event.
 
* define the events which will be passed to the backend
 
  l_event-eventid = cl_gui_column_tree=>EVENTID_NODE_DOUBLE_CLICK.
 
  append l_event to lt_events.
...

Regards

Uwe

9 REPLIES 9
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,010

Hello Ilhan

You need to register the double-click event:


form register_events.
 
* define the events which will be passed to the backend
 
  data: lt_events type cntl_simple_events,
 
  l_event type cntl_simple_event.
 
* define the events which will be passed to the backend
 
  l_event-eventid = cl_gui_column_tree=>EVENTID_NODE_DOUBLE_CLICK.
 
  append l_event to lt_events.
...

Regards

Uwe

Read only

0 Likes
1,009

I'm sorry but its still not working.

Reagrds

ertas

Read only

0 Likes
1,009

Hi,

you might not use on_double_click event in the tree control. because tree classes don't have double click evet.

Check it once again may be i am worg.

Check the below sample program in SE38

SAPTLIST_TREE_CONTROL_DEMO

SAPCOLUMN_TREE_CONTROL_DEMO

SAPSIMPLE_TREE_CONTROL_DEMO

Regards,

Boobalan Suburaj

Read only

0 Likes
1,009

Hi,

please refer to my local class:

It is for event of ITEM_DOUBLE_CLICK OF

CLASS lcl_handler DEFINITION.
  PUBLIC SECTION.
     CLASS-METHODS:
on_double_click FOR EVENT ITEM_DOUBLE_CLICK OF cl_gui_alv_tree_simple
 IMPORTING FIELDNAME INDEX_OUTTAB GROUPLEVEL.
ENDCLASS.                    "lcl_handler DEFINITION

Regards

ertas

Read only

0 Likes
1,009

Hello Ilhan

I did not read your posting carefully enough.

You need to register the double-click event for ITEMS and set the appropriate event handler.


form register_events.
 
* define the events which will be passed to the backend
 
  data: lt_events type cntl_simple_events,
 
  l_event type cntl_simple_event.
 
* define the events which will be passed to the backend
 
  l_event-eventid = cl_gui_column_tree=>EVENTID_ITEM_DOUBLE_CLICK.  " item, not node !!!
 
  append l_event to lt_events.
...

Regards

Uwe

Read only

0 Likes
1,009

hi,

what do you mean exactly

rgds

ertas

Read only

0 Likes
1,009

Hello Ilhan

You want to handle the double-click event on items:


CLASS lcl_handler DEFINITION.
  PUBLIC SECTION.
     CLASS-METHODS:
on_double_click FOR EVENT ITEM_DOUBLE_CLICK OF cl_gui_alv_tree_simple
 IMPORTING FIELDNAME INDEX_OUTTAB GROUPLEVEL.
ENDCLASS.                    "lcl_handler DEFINITION

I my first answer I proposed the wrong event for registering:


* define the events which will be passed to the backend
 
 * l_event-eventid = cl_gui_column_tree=>EVENTID_NODE_DOUBLE_CLICK.  " wrong event (node)
  l_event-eventid = cl_gui_column_tree=>EVENTID_ITEM_DOUBLE_CLICK.   " correct event (item)
 
  append l_event to lt_events.

Regards

Uwe

Read only

0 Likes
1,009

Hallo Uwe,

danke für die Antwort.

Bye

Ertas

Read only

Former Member
0 Likes
1,009

You should register event.

Also read this documentation

Registering Event Handler Methods

To allow an event handler method to react to an event, you must determine at runtime the trigger to which it is to react. You can do this with the following statement:

SET HANDLER... <hi>... [FOR]...

It links a list of handler methods with corresponding trigger methods. There are four different types of event.

It can be

An instance event declared in a class

An instance event declared in an interface

A static event declared in a class

A static event declared in an interface

The syntax and effect of the SET HANDLER depends on which of the four cases listed above applies.

For an instance event, you must use the FOR addition to specify the instance for which you want to register the handler. You can either specify a single instance as the trigger, using a reference variable <ref>:

SET HANDLER... <hi>...FOR <ref>.

or you can register the handler for all instances that can trigger the event:

SET HANDLER... <hi>...FOR ALL INSTANCES.

The registration then applies even to triggering instances that have not yet been created when you register the handler.

You cannot use the FOR addition for static events:

SET HANDLER... <hi>...

The registration applies automatically to the whole class, or to all of the classes that implement the interface containing the static event. In the case of interfaces, the registration also applies to classes that are not loaded until after the handler has been registered.