Skip to Content
0

Changing a node's site in the ALV tree

Jun 23, 2017 at 12:15 PM

74

avatar image

Hello experts,

i have an ALV tree and basically what i need to do is to slide (DRAG) a specific node to the top or bottom or a specific site in the ALV tree !

for example, here i wanna slide 'IF' node in place before 'AFFECATIONS' node :

=> Expected node's arrangement :

Any thoughts of how this is could be done ?

capture.jpg (48.5 kB)
prob.jpg (41.0 kB)
res.jpg (38.0 kB)
res.jpg (38.0 kB)
10 |10000 characters needed characters left characters exceeded

Please any help ?? i haven't found any soultion yet :(

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Sandra Rossi Jun 29, 2017 at 06:34 PM
0

There are the events ON_DRAG* and ON_DROP* so it should be possible. Did you use CL_GUI_ALV_TREE or CL_GUI_ALV_TREE_SIMPLE ?

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Heloo Sandra,

i used CL_GUI_ALV_TREE , what i m looking for just hoa to change the arrangement's nodes !!?

best regards.

Hamza CHIOUA.

0

Please any help ? i still haven't any solution for this task :/

0

You have these 2 demo programs:

  • BCALV_TREE_DND : Drag & Drop within a hierarchy tree
  • BCALV_TREE_DND_MULTIPLE : Drag & Drop within a hierarchy tree

They show how to use the events mentioned above.

Here are the most important lines of code for drag & drop handling for CL_GUI_ALV_TREE, which is for single node selection only:

CLASS lcl_dndobj definiTION.
  public section.
  methods constructor.
endclass."
CLASS lcl_dndobj IMPLEMENTATION.
  method constructor.
    "...
  endmethod."
endclass."

CLASS lcl_app DEFINITION.
  PUBLIC SECTION.
    METHODS on_drag
          FOR EVENT on_drag
          OF cl_gui_alv_tree
          IMPORTING
            DRAG_DROP_OBJECT
            FIELDNAME
            NODE_KEY
            sender.
    METHODS on_drop
          FOR EVENT on_drop
          OF cl_gui_alv_tree
          IMPORTING
            DRAG_DROP_OBJECT
            NODE_KEY
            sender.
ENDCLASS."

CLASS lcl_app IMPLEMENTATION.
  METHOD on_drag.
    " DRAG_DROP_OBJECT
    " FIELDNAME
    " NODE_KEY
    data: ls_output type ty_gs_alv_tree.
    CALL METHOD sender->get_outtab_line
      EXPORTING
        i_node_key     = node_key
      IMPORTING
        e_outtab_line  = ls_output
      EXCEPTIONS
        node_not_found = 1
        OTHERS         = 2.
    IF sy-subrc = 0.
      create object DRAG_DROP_OBJECT->object TYPE lcl_dndobj
          exporting 
            entity_id = ls_output-entity_id.
    ENDIF.
  ENDMETHOD."
 METHOD on_drop.
    " DRAG_DROP_OBJECT
    " NODE_KEY
   data: lo_dndobj TYPE REF TO lcl_dndobj.
   lo_dndobj ?= DRAG_DROP_OBJECT.
 ENDMETHOD."
ENDCLASS."

SET HANDLER go_app->on_drag FOR go_tree.
SET HANDLER go_app->on_drop FOR go_tree2.

You may also find more information at SAP Library: Drag and Drop.

0