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_drop does not work

Former Member
0 Likes
1,095

Dear All expert,

I am developing a program with CL_GUI_COLUMN_TREE.For the event on_drag, it works fine .But for the event on_drop, it never work.

But I need the drop works to reorganize the data of the internal table and user interface .I already register the event for the tree.

Also the local class to handle the event.

set handler dragdrop->handle_on_drag for g_alv_tree.

set handler dragdrop->handle_on_drop for g_alv_tree.

Thanks for your help in advance.

10 REPLIES 10
Read only

gerd_rother
Active Participant
0 Likes
1,034

Hi,

Please refer to the drag & drop examples in the workbench's control examples. It is enough to set the event handlers to successfully establish drag & drop, you need also an instance of class CL_DRAGDROP.

Regards, Gerd

Read only

0 Likes
1,034

Hi Thanks for your reply.

I already create a instance.also read the related sample.

CREATE OBJECT dragdrop.

  • set HANDLER DRAGDROP->handle_ON_DROP_GET_FLAVOR for g_alv_tree.

set handler dragdrop->handle_on_drag for g_alv_tree.

  • set handler dragdrop->handle_ON_DRAG_MULTIPLE for g_alv_tree.

set handler dragdrop->handle_on_drop for g_alv_tree.

  • set handler dragdrop->handle_ON_DROP_COMPLETE for g_alv_tree.

Read only

gerd_rother
Active Participant
0 Likes
1,034

Hi,

Did you also set the drag & drop handle id in your tree's items (received by the CL_DRAGDROP->GET_HANDLE method)?

Regards, Gerd

Read only

0 Likes
1,034

Yes. I did it.

The confusion is why it work for event on_drag but not work for ON_DROP.

Read only

gerd_rother
Active Participant
0 Likes
1,034

Hi,

Did you also call CL_DRAGDROP->ADD defining the drag & drop as source and target?

Like this:

method init_drag_n_drop.  " returning dd_id to be added to tree item definitions

data: dd_obj type ref to cl_dragdrop.

free dd_id.
create object dd_obj.
dd_obj->add( EXPORTING 
                              flavor = 'MY_FLAVOR'       " normally you use a meaningful constant here
                              dragsrc    = abap_true
                              droptarget = abap_true
                              effect     = cl_dragdrop=>copy ).
dd_obbj->get_handle( IMPORTING handle = dd_id ).

endmethod.

Gerd

Read only

0 Likes
1,034

Yes. I did it .The problem is it works already for on_drag.But I can not find the reason for why it does not work for on_drop

Read only

0 Likes
1,034

Can you show us the declaration of your Event handler class?

Regards,

Naimesh Patel

Read only

0 Likes
1,034

class lcl_dragdrop definiation.

public section.

class-methods :

handle_on_drag for event on_drap of cl_gui_column_tree

importing

node_key ...

handle_on_drop for event on_drag of cl_gui_column_tree

importing

node_key ....

endclass.

class lcl_dragdrop implementation.

method handle_on_drag.

endmethod.

method handle_on_drop

endmethod.

endclass.

Read only

gerd_rother
Active Participant
0 Likes
1,034

Hi,

If you did all of that it should work. Without the actual coding of setting up all the d&d behavior I cannot tell what is wrong.

Regards, Gerd

Read only

gerd_rother
Active Participant
0 Likes
1,034

Hi,

Thanks for the code portions you sent me.

I think here is what the problem is:

CLASS lcl_dragdrop_receiver DEFINITION.
  PUBLIC SECTION.
  METHODS:
  NODE_DOUBLE_CLICK for EVENT NODE_DOUBLE_CLICK of
  cl_gui_column_tree
  IMPORTING
    NODE_KEY,
   handle_ON_DRAG for EVENT on_DRAG of CL_GUI_COLUMN_TREE
    IMPORTING
       NODE_KEY ITEM_NAME DRAG_DROP_OBJECT,
   handle_on_drop for EVENT on_drop of cl_gui_column_tree
   IMPORTING
     NODE_KEY DRAG_DROP_OBJECT .
ENDCLASS.



CLASS lcl_dragdrop_receiver IMPLEMENTATION.
  METHOD: HANDLE_ON_DRAG.
    DATA drag_object TYPE REF TO lcl_drag_object.
    CREATE OBJECT drag_object.
    BREAK-POINT.
    IF DRAG_DROP_OBJECT->FLAVOR = 'Tree_move'."Move action.
      READ TABLE NODETABLE2 WITH KEY NODE_KEY = NODE_KEY
        INTO drag_object->DATA_NODE.

      LOOP AT ITEMTABLE2  INTO  ITEM2WA  WHERE NODE_KEY = NODE_KEY.
      APPEND ITEM2WA TO DRAG_OBJECT->DATA_ITM.
      ENDLOOP.
    ENDIF.
  ENDMETHOD.

The handle_on_drag method creates a local drag_object of type lcl_drag_object This should be used to pass information of the dragged data to the drop target. But this local object is not inserted into the event's parameter drag_drop_object (I think that attribute is named OBJECT?).

So while dropping the system realises that there is no dragged object and the event is not passed to your program.

Regards,

Gerd Rother