cancel
Showing results for 
Search instead for 
Did you mean: 

handle double click for alv_tree?

0 Kudos

hej out there,

as you may remember I'm doing some updates to UIs.

Somehow it should be possible to make alv_tree handle double_click events, shouldn't it?

I don't know how to go on. I found some methods but they don't work properly (or as expected).

I know there are methods to do so with simple_tree... hmpf. But it would be the worst solution to switch technique to simple_tree.

regards and thanks in advance,

BS

Accepted Solutions (1)

Accepted Solutions (1)

hymavathi_oruganti
Active Contributor
0 Kudos

THERE IS AN EVENT <b>NODE_DOUBLE_CLI</b>CK in <b>CL_GUI_ALV_TREE</b>.

handling that may help u!

0 Kudos

hej Hymavathi,

I already saw that method - but as I'm a abap-greenhorn I don't know how to handle this method because it's is modified <b>private</b>.

Do you?

regards and thanks,

BS

<b>EDIT:</b>

excuse me! I didn't see there is a method registered in "events" (only saw one in "methods" modified private!).

I'll give it a try!

Message was edited by: Boris Schoessow

hymavathi_oruganti
Active Contributor
0 Kudos

it is not method, it is event and it is public.

u can do like this

define a own class, in that write a method handling this event

in the impelementation of the class, write ur logic to handle the event.

write a SET HANDLER to handle the event.

see the example

class lcl_event_receiver definition.

method handle_double_click for node_double_click

of event cl_gui_alv_grid.

endclass.

class lcl_event_receiver implementation.

method handle_double_click.

perform handle_double_click.

endmethod.

DATA: EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.

create object event_receiver.

SET HANDLER EVENT_RECEIVER->NODE_DOUBLE_CLICK FOR GO_GRID.

note: go_grid type ref to cl_gui_alv_tree

former_member188685
Active Contributor
0 Kudos

Hi,

for node dible click, and item double click..

check the below...

CLASS lcl_tree_eventhandler DEFINITION.
  PUBLIC SECTION.
    METHODS:
             handle_double_click
             FOR EVENT node_double_click OF cl_gui_alv_tree
                  IMPORTING
                      node_key,
             handle_item_click
             FOR EVENT item_double_click OF cl_gui_alv_tree
                  IMPORTING
                      node_key
                      fieldname.




ENDCLASS.                              "lcl_tree_eventhandler DEFINITION
CLASS lcl_tree_eventhandler IMPLEMENTATION.

*****************************************************
*handle event for double click on node
  METHOD handle_double_click.

    PERFORM doubleclick_tree
       USING
         node_key.

  ENDMETHOD.                           "handle_double_click

****************************************************
*handle event for double click on item
  METHOD handle_item_click.

    PERFORM doubleclick_item_tree
       USING
         node_key
         fieldname.

  ENDMETHOD.                           "handle_item_click


ENDCLASS.                    "lcl_tree_eventhandler IMPLEMENTATION

Regards

vijay

former_member188685
Active Contributor
0 Kudos

Hi,

once you have defined, implemented , you need to set the handler

DATA: g_eventhandler TYPE REF TO lcl_tree_eventhandler.
create g_eventhandler.

    SET HANDLER g_eventhandler->handle_double_click FOR tree.
    SET HANDLER g_eventhandler->handle_item_click   FOR tree.

Regards

vijay

0 Kudos

hej,

      event-eventid = CL_GUI_SIMPLE_TREE=>eventid_node_double_click.
      event-appl_event = 'X' . " process PAI if event occurs
      APPEND event to events .

does anybody know which attribute I do have to assign instead of cl_gui_simple_tree=>(..)?

I can't find any appropriate.

former_member188685
Active Contributor
0 Kudos

Hi,

what is the class you are using is it cl_gui_alv_tree or

cl_gui_simple_tree.

if it is cl_gui_alv_tree then you should handle it with the event handler , there no event id for double click..

Regards

vijay

former_member188685
Active Contributor
0 Kudos

Hi,

what is the class you are using is it cl_gui_alv_tree or

cl_gui_simple_tree.

if it is cl_gui_alv_tree then you should handle it with the event handler , there no event id for double click..

Regards

vijay

0 Kudos

hej vijay,

I'm using cl_gui_alv_tree!

So... regestering events is only for some classes? Do you know where can I look it up? Something like a short overview would be very helpful...

a big thanks,

BS

hymavathi_oruganti
Active Contributor
0 Kudos

what u want to register?

for data_changed event, u need to register.

for double_click no need.

there is an event LEFT_CLICK_DESIGN which may serve ur purpose of single click

former_member188685
Active Contributor
0 Kudos

Hi,

there is no events to register for double click, so definitely you should go for local class to handle the event as mentioned in my previous reply..

so try to implement the double click event and set the handler for it.if you see the attributes of cl_gui_alv_tree there is no event id for the double click. but there are events for the same.

Regards

vijay

0 Kudos

hi Boris,

try to use this event handler

data: EVENTS TYPE CNTL_SIMPLE_EVENTS,

event type cntl_simple_event.

event-eventid = CL_GUI_list_TREE=>EVENTID_NODE_DOUBLE_CLICK.

event-appl_event = 'X'.

append event to events.

Regards

Waleed

0 Kudos

Hej together,

the report finally does not terminate anymore because of event handling.

But now I'm stuck on how to transport data from the "double-click" to other fields on the dnypro!

regards,

BS

former_member188685
Active Contributor
0 Kudos

hi,

CL_GUI_list_TREE is not the supe class of cl_gui_alv_tree so you cannot use it for that purpose..

Regards

vijay

hymavathi_oruganti
Active Contributor
0 Kudos

the event exports node_key, with which u can do

0 Kudos

seems to be fine!

is there a smarter solution to add the data of the double clicked node to an alv grid in the same dynpro then adding the data to the itab and calling screen again?

regards and thanks for answering newbie questions

BS

former_member188685
Active Contributor
0 Kudos

Hi,

there is solution for it, using list tree you can do that.., the class is cl_gui_list_tree, here you can use tree as well as Grid .

one simple example for list tree is <b>SAPTLIST_TREE_CONTROL_DEMO</b>

here they used normal screen, instead you have to use custom container and proceed..

same strory, create container, add grid to that...

Regards

vijay

0 Kudos

Hej,

I gotta do it using alv-tree.

And I tried it the following way (just did a short and quick example which remains fundamentally the same to my old report).

But the way it's done in the following code snipped it won't work... if decomment


*    event-eventid = cl_gui_alv_tree=>eventid_node_double_click .
*    event-appl_event = ' ' .
*
*    APPEND event TO events .

the message will be raised telling node double click has been handled... but not a single node can be expanded anymore.

CLASS event DEFINITION.
  PUBLIC SECTION.
    METHODS:
      handle_node_dblclick
        FOR EVENT node_double_click
               OF cl_gui_alv_tree
        IMPORTING node_key.
ENDCLASS.

CLASS event IMPLEMENTATION.
  METHOD handle_node_dblclick.
    DATA:
      l_carrid TYPE spfli-carrid,
      l_connid TYPE spfli-connid.

    l_carrid = node_key(2).
    l_connid = node_key+2(4).

    MESSAGE i001(ZBOBOPP1) WITH 'handled double click'
                                l_carrid
                                l_connid .
  ENDMETHOD.
ENDCLASS.

  DATA:
    ctrlcontainer TYPE REF TO cl_gui_docking_container ,
    treectrl      TYPE REF TO cl_gui_alv_tree ,
    evt           TYPE REF TO event ,

    tblpointer    TYPE TABLE OF scustom ,

    fieldcat      TYPE lvc_t_fcat ,

    hierhead      TYPE treev_hhdr ,
    
    events        TYPE cntl_simple_events ,
    event         TYPE cntl_simple_event .

MODULE status_0100 OUTPUT.

  SET PF-STATUS 'S_100'.
  SET TITLEBAR 'T_100'.

  IF ctrlcontainer IS INITIAL .
  
    CREATE OBJECT evt.

    CREATE OBJECT ctrlcontainer
      EXPORTING
        extension = 900 .

    CREATE OBJECT treectrl
      EXPORTING
        parent         = ctrlcontainer
        no_html_header = 'X' .

    PERFORM adjcolarea
      CHANGING fieldcat.

    hierhead-heading   = 'Land/Kundenname/Kunde'(300).
    hierhead-tooltip   = 'Name des Kunden'(400).
    hierhead-width     = 45.
    hierhead-width_pix = space.

    CALL METHOD treectrl->set_table_for_first_display
      EXPORTING
        is_hierarchy_header = hierhead
      CHANGING
        it_outtab           = tblpointer
        it_fieldcatalog     = fieldcat.

************
*    event-eventid = cl_gui_alv_tree=>eventid_node_double_click .
*    event-appl_event = ' ' .
*
*    APPEND event TO events .
*
*    CALL METHOD treectrl->set_registered_events
*      EXPORTING
*        events = events .
*
    SET HANDLER evt->handle_node_dblclick FOR treectrl .
***********

    PERFORM select_data_and_fill_col_tree .


    CALL METHOD treectrl->frontend_update .

    CALL METHOD cl_gui_cfw=>flush .

  ENDIF .

ENDMODULE .                 " STATUS_0100  OUTPUT

Thanks,

BS

Message was edited by: Boris Schoessow

former_member188685
Active Contributor
0 Kudos

Hi Boris,

in one of my development i referred the sample Program

<b>RCCUBD00</b> , here they implemented node double click.

check the include of the same program <b>RCCUBD00C01</b>

this will help you a lot...

Check it.

Regards

vijay

0 Kudos

hej vijay,

this report seems to be just fine... !

wow

I'll try to become acquainted with this report to transfer it.

I'll response asap again.

thanks a lot,

BS

0 Kudos

hej vijay,

seems to really fine. But I searched without success for any comments explaining why you first get registered events, then set some and clear.. and then get it again.


    PERFORM get_registered_events
       CHANGING
         lt_reg_events.

    PERFORM set_registered_events
       CHANGING
         lt_reg_events.

    CLEAR lt_reg_events.

    PERFORM get_registered_events
       CHANGING
         lt_reg_events.


    SET HANDLER g_eventhandler->handle_double_click FOR tree.

    SET HANDLER g_eventhandler->handle_item_click   FOR tree.

EDIT: Don't get me wrong. It's working now... but I would like to know why

(As I remember I did something similar - registering events etc.) sigh

Message was edited by: Boris Schoessow

former_member188685
Active Contributor
0 Kudos

Hi,

PERFORM get_registered_events
       CHANGING
         lt_reg_events.

the above one will get the registered events if any,

what ever you get it , now you are setting them to your application using the below if there are no registered events

  PERFORM set_registered_events
       CHANGING
         lt_reg_events.

"lt_reg_events is a internal table

CLEAR lt_reg_events

"this is clearing the header

"not the table as such

"now they are again getting the registered events

   PERFORM get_registered_events
       CHANGING
         lt_reg_events.

"the below two are set handlers for double click and item click.

 SET HANDLER g_eventhandler->handle_double_click FOR tree.
 
 SET HANDLER g_eventhandler->handle_item_click   FOR tree.

Regards

vijay

Message was edited by: Vijay Babu Dudla

former_member188685
Active Contributor
0 Kudos

Hi Boris,

registered events thing will work only when there is any application events available , you can find them in attributes of class. only those events which they have event id's can be registered. but for the other events we have option of setting handlers and triggering them.

Great your problem solved

Regards

vijay

former_member188685
Active Contributor
0 Kudos

Hi Boris,

if your problem solved please close this thread, and reward helpful answers.

Regards

vijay

0 Kudos

Hej Vijay,

I'll close the thread and do rewards after I can confirm that there won't pop up any more questions about this topic.

Still I have some problems left to solve. For example, how do I get the layers (children) assigned to one node and transport in an ALV Grid (at best without reloading everytime the dynpro).

Thanks a lot,

you are great!

BS

PS: is within SDN a private messaging tool available? wondering

former_member188685
Active Contributor
0 Kudos

hi,

after double_click, get the nodekey read the item tables

and show it in the grid. no need of reloading the dynpro but you need to call the method

 CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY
    EXCEPTIONS
      FINISHED = 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.

but you need to pass the item table for corresponding node key to grid.

"there is no private messaging tool as such

"but you can mail using business card

Regards

vijay

0 Kudos

Hej,

thank you very very much Vija!

Well I think I had been at that point... but forgot to move an old routine which seems to be reloading some stuff.

However - do you know if there is any smarter way for saving a node and its children than looping with LOOP AT? I think it'll be really slow if I have thousands of results.

kind regards,

BS

former_member188685
Active Contributor
0 Kudos

Hi Boris,

Looping only best way to get the children data, but try to pass the node key in where condition and loop.

some thing like this..

loop at itab where condition.

endloop.

This will be faster than what you are doing.

Regards

vijay

Answers (2)

Answers (2)

0 Kudos

Hej,

just to clarify things for me -

do I have to handle single clicks now on my own?

Because if I do click a node (and it should expand) it won't show anything.

thanks a lot-

you're just great!

BS

Former Member
0 Kudos

hi Boris,

You can try this link .

http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_basic.htm

Cheers

Sunny

Rewrd points if link is helpful