Complicated drap and drop

Hello, I am trying to do something with my drag and drop game
that is too complicated for me to find on any tutorial.
I am trying to set it up so that when the item is being
dragged and it is over the correct drop area, the item blinks
(which I have animated on the 2nd frame and beyond in each item).
The problem is, I can't seem to run a hitTest while the item is
being dragged, or onPress of the item. I have even tried to set an
interval so that my indicator function runs every 50 milliseconds.
I have included the sample script below, if anyone could help me it
would be greatly appreciated.
//------//var intervalId:Number
function indicator(item,labels){
if(eval(item).target_mc.hitTest(eval(labels).target_mc)){
eval(item).gotoAndStop(2);
//-------//intervalId = setInterval(indicator, 50);
function labelsTest(item,labels){
eval(item).stopDrag();
if(eval(item).target_mc.hitTest(eval(labels).target_mc)){
eval(labels).gotoAndStop(2);
eval(item).enabled=false;
eval(item)._visible=false;
counter++;
if (counter==7){gotoAndStop("continue");
item1_mc.onPress = function () {
item1_mc.startDrag();
item1_mc.swapDepths(this.getNextHighestDepth());
indicator("item1_mc","label1_mc");
item1_mc.onRelease = function () {
labelsTest("item1_mc","label1_mc");
}

Allright, the reason why I am setting them as strings is
because I have a lot more movie clip(draggable items) than I
included the code for. I have tried a couple of your suggestions
and it doesn't seem like the hitTest is operating at all while the
mouse is pressed. here are a couple things that I have tried
function indicator(item,labels){
if(eval(item).target_mc.hitTest(eval(labels).target_mc)){
eval(item).gotoAndPlay(2);
function labelsTest(item,labels){
eval(item).stopDrag();
if(eval(item).target_mc.hitTest(eval(labels).target_mc)){
eval(labels).gotoAndStop(2);
eval(item)._x=eval(labels)._x;
eval(item)._y=eval(labels)._y;
eval(item).enabled=false;
eval(item)._visible=false;
clearinterval(intervalId);
counter++;
if (counter==7){gotoAndStop("continue");
item1_mc.onPress = function () {
item1_mc.startDrag();
item1_mc.swapDepths(this.getNextHighestDepth());
var intervalId:Number
indicator("item1_mc","label1_mc");
intervalId = setInterval(indicator, 50);
I have also tried to set my interval like this
intervalId = setInterval(indicator("item1_mc","label1_mc"),
50);
Thanks a bunch for your feedback on this,

Similar Messages

  • [Solved] Dophin 4.8 doesn't drap and drop to remote locations

    I think I've found a really really minor bug in Dolphin: When I try to drap and drop a file from one tab/window of Dolphin locally, it always works and presents the expected dialogue to decide whether I want to move, copy etc. But when the source is local and the target remote (namely,  a samba computer) it doesn't. The reverse (remote to local) works. Has anyone noticed it before? Can anyone reproduce it?
    Thanks
    Last edited by GordonGR (2012-02-08 21:18:20)

    Already fixed for 4.8.1
    http://bugs.kde.org/show_bug.cgi?id=292821

  • Swing drap and drop ?

    How can i make the act drap and drop in swing?

    Hi zhenglan!
    I found examples of Drag&Drop (for Swing) at:
    http://developer.java.sun.com/developer/codesamples/examplets/index.html
    Best Regards.

  • How can I use Drap and Drop in Linux system?

    I try to use DnD in a item from "explorer" in Linux into my application, but it does atually not work. The same version is work well on Windows. Below is code (3 separated files):
    * FileAndTextTransferHandler.java is used by the 1.4
    * DragFileDemo.java example.
    import java.io.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.datatransfer.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    class FileAndTextTransferHandler extends TransferHandler {
        private DataFlavor fileFlavor, stringFlavor;
        private TabbedPaneController tpc;
        private JTextArea source;
        private boolean shouldRemove;
        protected String newline = "\n";
        //Start and end position in the source text.
        //We need this information when performing a MOVE
        //in order to remove the dragged text from the source.
        Position p0 = null, p1 = null;
        FileAndTextTransferHandler(TabbedPaneController t) {
           tpc = t;
           fileFlavor = DataFlavor.javaFileListFlavor;
           stringFlavor = DataFlavor.stringFlavor;
        public boolean importData(JComponent c, Transferable t) {
            JTextArea tc;
            if (!canImport(c, t.getTransferDataFlavors())) {
                return false;
            //A real application would load the file in another
            //thread in order to not block the UI.  This step
            //was omitted here to simplify the code.
            try {
                if (hasFileFlavor(t.getTransferDataFlavors())) {
                    String str = null;
                    java.util.List files =
                         (java.util.List)t.getTransferData(fileFlavor);
                    for (int i = 0; i < files.size(); i++) {
                        File file = (File)files.get(i);
                        //Tell the tabbedpane controller to add
                        //a new tab with the name of this file
                        //on the tab.  The text area that will
                        //display the contents of the file is returned.
                        tc = tpc.addTab(file.toString());
                        BufferedReader in = null;
                        try {
                            in = new BufferedReader(new FileReader(file));
                            while ((str = in.readLine()) != null) {
                                tc.append(str + newline);
                        } catch (IOException ioe) {
                            System.out.println(
                              "importData: Unable to read from file " +
                               file.toString());
                        } finally {
                            if (in != null) {
                                try {
                                    in.close();
                                } catch (IOException ioe) {
                                     System.out.println(
                                      "importData: Unable to close file " +
                                       file.toString());
                    return true;
                } else if (hasStringFlavor(t.getTransferDataFlavors())) {
                    tc = (JTextArea)c;
                    if (tc.equals(source) && (tc.getCaretPosition() >= p0.getOffset()) &&
                                             (tc.getCaretPosition() <= p1.getOffset())) {
                        shouldRemove = false;
                        return true;
                    String str = (String)t.getTransferData(stringFlavor);
                    tc.replaceSelection(str);
                    return true;
            } catch (UnsupportedFlavorException ufe) {
                System.out.println("importData: unsupported data flavor");
            } catch (IOException ieo) {
                System.out.println("importData: I/O exception");
            return false;
        protected Transferable createTransferable(JComponent c) {
            source = (JTextArea)c;
            int start = source.getSelectionStart();
            int end = source.getSelectionEnd();
            Document doc = source.getDocument();
            if (start == end) {
                return null;
            try {
                p0 = doc.createPosition(start);
                p1 = doc.createPosition(end);
            } catch (BadLocationException e) {
                System.out.println(
                  "Can't create position - unable to remove text from source.");
            shouldRemove = true;
            String data = source.getSelectedText();
            return new StringSelection(data);
        public int getSourceActions(JComponent c) {
            return COPY_OR_MOVE;
        //Remove the old text if the action is a MOVE.
        //However, we do not allow dropping on top of the selected text,
        //so in that case do nothing.
        protected void exportDone(JComponent c, Transferable data, int action) {
            if (shouldRemove && (action == MOVE)) {
                if ((p0 != null) && (p1 != null) &&
                    (p0.getOffset() != p1.getOffset())) {
                    try {
                        JTextComponent tc = (JTextComponent)c;
                        tc.getDocument().remove(
                           p0.getOffset(), p1.getOffset() - p0.getOffset());
                    } catch (BadLocationException e) {
                        System.out.println("Can't remove text from source.");
            source = null;
        public boolean canImport(JComponent c, DataFlavor[] flavors) {
            if (hasFileFlavor(flavors))   { return true; }
            if (hasStringFlavor(flavors)) { return true; }
            return false;
        private boolean hasFileFlavor(DataFlavor[] flavors) {
            for (int i = 0; i < flavors.length; i++) {
                if (fileFlavor.equals(flavors)) {
    return true;
    return false;
    private boolean hasStringFlavor(DataFlavor[] flavors) {
    for (int i = 0; i < flavors.length; i++) {
    if (stringFlavor.equals(flavors[i])) {
    return true;
    return false;
    * TabbedPaneController.java is used by the 1.4
    * DragFileDemo.java example.
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    * Class that manages area where the contents of
    * files are displayed.  When no files are present,
    * there is a simple JTextArea instructing users
    * to drop a file.  As soon as a file is dropped,
    * a JTabbedPane is placed into the window and
    * each file is displayed under its own tab.
    * When all the files are removed, the JTabbedPane
    * is removed from the window and the simple
    * JTextArea is again displayed.
    public class TabbedPaneController {
        JPanel tabbedPanel = null;
        JTabbedPane tabbedPane;
        JPanel emptyFilePanel = null;
        JTextArea emptyFileArea = null;
        FileAndTextTransferHandler transferHandler;
        boolean noFiles = true;
        String fileSeparator;
        public TabbedPaneController(JTabbedPane tb, JPanel tp) {
            tabbedPane = tb;
            tabbedPanel = tp;
            transferHandler = new FileAndTextTransferHandler(this);
            fileSeparator = System.getProperty("file.separator");
            //The split method in the String class uses
            //regular expressions to define the text used for
            //the split.  The forward slash "\" is a special
            //character and must be escaped.  Some look and feels,
            //such as Microsoft Windows, use the forward slash to
            //delimit the path.
            if ("\\".equals(fileSeparator)) {
                fileSeparator = "\\\\";
            init();
        public JTextArea addTab(String filename) {
            if (noFiles) {
                tabbedPanel.remove(emptyFilePanel);
                tabbedPanel.add(tabbedPane, BorderLayout.CENTER);
                noFiles = false;
            String[] str = filename.split(fileSeparator);
            return makeTextPanel(str[str.length-1], filename);
        //Remove all tabs and their components, then put the default
        //file area back.
        public void clearAll() {
            if (noFiles == false) {
                tabbedPane.removeAll();
                tabbedPanel.remove(tabbedPane);
            init();
        private void init() {
            String defaultText =
                "Select one or more files from the file chooser and drop here...";
            noFiles = true;
            if (emptyFilePanel == null) {
                emptyFileArea = new JTextArea(20,15);
                emptyFileArea.setEditable(false);
                emptyFileArea.setDragEnabled(true);
                emptyFileArea.setTransferHandler(transferHandler);
                emptyFileArea.setMargin(new Insets(5,5,5,5));
                JScrollPane fileScrollPane = new JScrollPane(emptyFileArea);
                emptyFilePanel = new JPanel(new BorderLayout(), false);
                emptyFilePanel.add(fileScrollPane, BorderLayout.CENTER);
            tabbedPanel.add(emptyFilePanel, BorderLayout.CENTER);
            tabbedPanel.repaint();
            emptyFileArea.setText(defaultText);
        protected JTextArea makeTextPanel(String name, String toolTip) {
            JTextArea fileArea = new JTextArea(20,15);
            fileArea.setDragEnabled(true);
            fileArea.setTransferHandler(transferHandler);
            fileArea.setMargin(new Insets(5,5,5,5));
            JScrollPane fileScrollPane = new JScrollPane(fileArea);
            tabbedPane.addTab(name, null, (Component)fileScrollPane, toolTip);
            tabbedPane.setSelectedComponent((Component)fileScrollPane);
            return fileArea;
    * DragFileDemo.java is a 1.4 example that
    * requires the following file:
    *    FileAndTextTransferHandler.java
    *    TabbedPaneController.java
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    public class DragFileDemo extends JPanel
                              implements ActionListener {
        JTextArea fileArea;
        JFileChooser fc;
        JButton clear;
        TabbedPaneController tpc;
        public DragFileDemo() {
            super(new BorderLayout());
            fc = new JFileChooser();;
            fc.setMultiSelectionEnabled(true);
            fc.setDragEnabled(true);
            fc.setControlButtonsAreShown(false);
            JPanel fcPanel = new JPanel(new BorderLayout());
            fcPanel.add(fc, BorderLayout.CENTER);
            clear = new JButton("Clear All");
            clear.addActionListener(this);
            JPanel buttonPanel = new JPanel(new BorderLayout());
            buttonPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
            buttonPanel.add(clear, BorderLayout.LINE_END);
            JPanel upperPanel = new JPanel(new BorderLayout());
            upperPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
            upperPanel.add(fcPanel, BorderLayout.CENTER);
            upperPanel.add(buttonPanel, BorderLayout.PAGE_END);
            //The TabbedPaneController manages the panel that
            //contains the tabbed pane.  When there are no files
            //the panel contains a plain text area.  Then, as
            //files are dropped onto the area, the tabbed panel
            //replaces the file area.
            JTabbedPane tabbedPane = new JTabbedPane();
            JPanel tabPanel = new JPanel(new BorderLayout());
            tabPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
            tpc = new TabbedPaneController(tabbedPane, tabPanel);
            JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
                upperPanel, tabPanel);
            splitPane.setDividerLocation(400);
            splitPane.setPreferredSize(new Dimension(530, 650));
            add(splitPane, BorderLayout.CENTER);
        public void setDefaultButton() {
            getRootPane().setDefaultButton(clear);
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == clear) {
                tpc.clearAll();
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("DragFileDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the menu bar and content pane.
            DragFileDemo demo = new DragFileDemo();
            demo.setOpaque(true); //content panes must be opaque
            frame.setContentPane(demo);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
            demo.setDefaultButton();
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();

    I'm currently using Linux Fedora system.
    Doesn't matter. There's no standard way for D&D on Linux, no single API.
    Every application has its own mechanism which may or may not be compatible with any other.
    Gnome and KDE groups are doing some work to provide a common standard but as you know the Linux zealots are completely opposed to anyone telling them what to do (such as creating standards) and won't in general follow them.

  • Drap and Drop between MS-Word and a Java-Applet

    Hi,
    i've read that it is possible to drag a text in an applet and to drop it on a word document. Somebody know if it is possbile to do it the other way round ? To drag a text within a word document and to drop it on an applet.
    thanks a lot

    How about dragging text from Word and dropping on JTextArea? Check the source of VietPad (http://sourceforge.net/projects/vietpad) for a working example.

  • How do i drap and drop files onto my juk drive

    How do i drag and drop files and photos into my lexar juk drive?

    You do only get an alias appearing for the files that you want to burn. But when you click on the Burn icon in the Finder sidebar, the files will be burnt to the disc.

  • DW CS5 allow visual design (drap and drop?)

    Does DW have a feature to allow one to visually design by dragging objects onto the form?  For example, there are visual elements of buttons and lists, table that I just click and drag onto the form?  if so, what is the process/steps to get that turned on or to see those features?  Thanks.

    Hey Brad,
    What I would like to do since I am not so skilled with HTML/CSS is to use Fireworks to layout webpages visually by dropping those components onto form.  I would do better by visually designing a look and feel.  Once I have done that in Fireworks, does that export into HTML/CSS so that it can be worked with in Dreamweaver for fine tuning?
    To further expand what I am wanting to do is that years ago I had used Adobe GoLive that allowed me to just drag and drop html components (buttons, text boxes, lists, images, etc) right onto form.  How can I do that in Dreamweaver?  Maybe Fireworks isn't the right program to use.  I guess I am asking to what happened to that type of features of drag&drop that was in the Adobe GoLive product?
    Thanks...
    Steven

  • I can't drag and drop or cut and paste all of a sudden! Help

    I can't drap and drop or cut and paste all of a sudden.  I updated my windows suite and ditched the old stuff.  The next day no drag, drop, cut and paste.
    <Email Edited By Host>

    *FireFTP: https://addons.mozilla.org/firefox/addon/fireftp/

  • How to I drag and drop from Customize Add On using a Wireless Mouse on a Laptop?

    I have been assisting a friend in installing Firefox. I have added Add On, but I cannot drag and drop them into the toolbars on the top. The tiny weenie add on tool bar stinks for those of us who are older and have weakened eyesight. How Can I Drap and Drop into the Toolbars on the Top using a laptop without a mouse?

    PS. I also tried drag-and-dropping to Photoshop, and it doesn't work either.
    I did more research online, and the more I research this, the more it seems that the LIGHTROOM DRAG AND DROP functionality works on MAC but not on PC...
    If it is the case, this would be a major annoyance.
    Some people said this feature worked on PC in Windows Vista.
    I tried running LR in compatibility more (Vista SP2), but this did not fix the issue.
    I am starting to wonder if this is a problem with LR running on WINDOWS x64 systems... (I am running WIN7 x64)

  • Drag and Drop between Web Dynpro Tables on Cell Basis

    Hi Experts,
    I need to develop a Drag and Drop Functionality as follows:
    I have two tables. I want to drag a row of the first table and drop it in a particular cell of the second table.
    Is it possible to implement this using the Web Dynpro Drap and Drop Functionality?
    If not, does anybody have an idea of how to implement this using other concepts (Flash Integration, Building up a Grid of Images and defining those as drop tragets, etc..)??
    Valuable Advice is highly appreciated!
    THANKS, Johannes

    Thanks for the Video.. It gives some information about Drag and Drop, but still, it does not say what I need to know.
    Again:
    I need to know if there is a way to drag particular cells in a Web Dynpro Table to other locations in that same table. Plus: I need to know if there is a way to drag and drop rows of one table into particular cell of another table.
    Similar to what we do in our Outlook Calendars: We have a week in view and we see our appointments as blocks within that week view. Now, we can drag and drop these blocks to other locations. That is what I need to implement!
    Does anybody have an idea?
    THANKS, Johannes

  • Drag and Drop between two ALV Tree Controls

    Hello all,
    I have designed a spilt control of two ALV Trees using CL_GUI_ALV_TREE.
    I have a top node as the Sales order Number and the child node as the items belonging to that sales order number.
    Now i need to drag and drop the lines from one sales order to another.
    Also these drag drop can take place between the nodes of the two different trees.
    Can someone provide with a detail example as i need to complete the same urgently.
    Regards,
    Arun

    Once check the Below code For tree to tree drag an drop
    *       CLASS lcl_main DEFINITION
    CLASS lcl_main  DEFINITION.
      PUBLIC SECTION.
    * Types
        TYPES:
                BEGIN OF  t_ekpo,
                  ebeln TYPE ebeln,
                  ebelp TYPE ebelp,
                END OF    t_ekpo.
        TYPES:
                BEGIN OF  t_vbap,
                  vbeln TYPE vbeln,
                  posnr TYPE vbelp,
                END OF    t_vbap.
    * Internal Tables
        DATA:
              i_ekpo        TYPE STANDARD TABLE OF t_ekpo,
              i_ekpo_op     TYPE STANDARD TABLE OF t_ekpo,
              i_vbap        TYPE STANDARD TABLE OF t_vbap,
              i_vbap_op     TYPE STANDARD TABLE OF t_vbap,
              i_fcat_ekpo   TYPE                   lvc_t_fcat,
              i_fcat_vbap   TYPE                   lvc_t_fcat.
    * Work Areas
        DATA:
              wa_ekpo   TYPE t_ekpo,
              wa_ekpo1  TYPE t_ekpo,
              wa_vbap   TYPE t_vbap,
              wa_vbap1  TYPE t_vbap.
    * Data Declarations
        DATA:
              g_ebeln TYPE ebeln,
              g_vbeln TYPE vbeln_va.
        DATA: g_variant          TYPE disvariant,
              g_hierarchy_header TYPE treev_hhdr,
              g_handle_drag      TYPE i,
              g_handle_drop      TYPE i.
    * Class data
        DATA:
              splitter    TYPE REF TO cl_gui_splitter_container,
              container   TYPE REF TO cl_gui_custom_container,
              container_1 TYPE REF TO cl_gui_container,
              container_2 TYPE REF TO cl_gui_container,
              tree1       TYPE REF TO cl_gui_alv_tree,
              tree2       TYPE REF TO cl_gui_alv_tree,
              g_drag      TYPE REF TO cl_dragdrop,
              g_drop      TYPE REF TO cl_dragdrop.
    * Constants
        CONSTANTS:
                  c_30(2) TYPE c VALUE '30'.
    * Methods
        METHODS:
                  get_data,                          " Data Fatch
                  build_display,                     " Display Container
                  display_ekpo,                      " Ekpo table display
                  display_vbap,                      " Vbap table display
                  add_node_ekpo                      " Add node to Ekpo
                    IMPORTING table  TYPE t_ekpo
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                              flag   TYPE c
                    CHANGING  i_key  TYPE lvc_nkey,
                  add_node_vbap                      " Add node to vbap
                    IMPORTING table  TYPE t_vbap
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                              flag   TYPE c
                    CHANGING  i_key  TYPE lvc_nkey,
                  dnd_behaviour,                     " Drag and drop behavour
                  register_events_ekpo,              " Register Events Ekpo
                  register_events_vbap,              " Register events vbap
                  handle_drag_multiple               " Drag Multiple Values
                     FOR EVENT on_drag_multiple
                     OF cl_gui_alv_tree
                     IMPORTING sender node_key_table fieldname drag_drop_object,
                  handle_drop                        " Drop the values
                     FOR EVENT on_drop
                     OF cl_gui_alv_tree
                     IMPORTING sender node_key drag_drop_object,
                  add_node_drop                      " Add node to Drop Node
                    IMPORTING table  TYPE t_ekpo
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                    CHANGING  i_key  TYPE lvc_nkey.
    ENDCLASS.                                        " Lcl_main DEFINITION
    *       CLASS LCL_DRAGOBJ DEFINITION
    * Drag And drop Structure
    CLASS lcl_dragobj DEFINITION INHERITING FROM lcl_main FINAL.
      PUBLIC SECTION.
    * Types
        TYPES: BEGIN OF t_node_info,
                  l_ekpo      TYPE t_ekpo,
                  l_node_text TYPE lvc_value,
                  l_node_key  TYPE lvc_nkey,
               END OF t_node_info.
    * Data
        DATA: i_node_info  TYPE TABLE OF t_node_info,
              wa_node_info TYPE t_node_info.
    ENDCLASS.                                        " LCL_DRAGOBJ DEFINITION
    * Object Declarations
    DATA  obj_main  TYPE REF TO lcl_main.
    * Initialization                                                     *
    INITIALIZATION.
      CREATE OBJECT obj_main.
    * Selection Screen                                                   *
      SELECTION-SCREEN  BEGIN OF BLOCK  block1  WITH FRAME.
      SELECT-OPTIONS:
                      s_ebeln FOR obj_main->g_ebeln,
                      s_vbeln FOR obj_main->g_vbeln MATCHCODE OBJECT  cs_vbeln.
      SELECTION-SCREEN  END OF   BLOCK  block1.
    * Start of Selection                                                 *
    START-OF-SELECTION.
    * Call Screen
      CALL SCREEN 100.
    *       CLASS lcl_main IMPLEMENTATION
    * Local class Implementation
    CLASS lcl_main  IMPLEMENTATION.
    * Get Data                                                           *
      METHOD  get_data.
    * Data from Ekpo
        SELECT  ebeln
                ebelp
          FROM  ekpo
          UP TO 100 ROWS
          INTO  TABLE i_ekpo
         WHERE  ebeln IN  s_ebeln.
    * Data from Vbap
        SELECT  vbeln
                posnr
          FROM  vbap
          UP TO 100 ROWS
          INTO  TABLE i_vbap
         WHERE  vbeln IN  s_vbeln.
      ENDMETHOD.                                     " Get_data
    * Build Display                                                      *
      METHOD  build_display.
    * Create Container
        CREATE OBJECT container
          EXPORTING
            container_name = 'CUST_CONT'.
    * Split the container
        CREATE OBJECT splitter
          EXPORTING
            parent  = container
            rows    = 1
            columns = 2.
        CALL METHOD splitter->get_container
          EXPORTING
            row       = 1
            column    = 1
          RECEIVING
            container = container_1.
        CALL METHOD splitter->get_container
          EXPORTING
            row       = 1
            column    = 2
          RECEIVING
            container = container_2.
    * create tree control
        CREATE OBJECT tree1
          EXPORTING
            parent                      = container_1
            node_selection_mode         = cl_gui_column_tree=>node_sel_mode_multiple
            item_selection              = 'X'
            no_html_header              = 'X'
            no_toolbar                  = 'X'
          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.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
        CREATE OBJECT tree2
          EXPORTING
            parent                      = container_2
            node_selection_mode         = cl_gui_column_tree=>node_sel_mode_multiple
            item_selection              = 'X'
            no_html_header              = 'X'
            no_toolbar                  = 'X'
          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.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
        g_variant-report      = sy-repid.
        g_variant-handle      = space.
        g_variant-log_group   = space.
        g_variant-username    = space.
        g_variant-text        = space.
        g_variant-dependvars  = space.
    * Call method for get data
        CALL METHOD get_data.
    * Drap And Drop behaviour method
        CALL METHOD dnd_behaviour.
    * Display the Ekpo table
        CALL METHOD obj_main->display_ekpo.
    * Diaplay the vbap table
        CALL METHOD obj_main->display_vbap.
        CALL METHOD tree1->frontend_update.
        CALL METHOD tree2->frontend_update.
      ENDMETHOD.                                     " Build_display
    * Display EKPO                                                       *
      METHOD  display_ekpo.
    * Data
        DATA:
              l_key1 TYPE lvc_nkey,
              l_key2 TYPE lvc_nkey,
              l_key3 TYPE lvc_nkey,
              l_node_text TYPE lvc_value.
    * ALV control service modules
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_buffer_active        = 'X'
            i_structure_name       = 'EKPO'
            i_client_never_display = 'X'
            i_bypassing_buffer     = space
          CHANGING
            ct_fieldcat            = i_fcat_ekpo
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc EQ 0.
          DELETE i_fcat_ekpo FROM 4.
        ENDIF.                                       " IF sy-subrc EQ 0.
        g_hierarchy_header-heading = 'Purchase Order Details'(001).
        g_hierarchy_header-tooltip = 'Purchase Order'(002).
        g_hierarchy_header-width = c_30.
        g_hierarchy_header-width_pix = ' '.
    * Diaply
        CALL METHOD tree1->set_table_for_first_display
          EXPORTING
            is_hierarchy_header = g_hierarchy_header
            is_variant          = g_variant
          CHANGING
            it_outtab           = obj_main->i_ekpo_op
            it_fieldcatalog     = i_fcat_ekpo.
        LOOP AT i_ekpo  INTO  wa_ekpo1.
          MOVE wa_ekpo1 TO wa_ekpo.
          l_key1  = ''.
          AT NEW  ebeln.
            MOVE wa_ekpo-ebeln  TO l_node_text.
    * Call method for Add Node to Ekpo
            CALL METHOD add_node_ekpo
              EXPORTING
                table = wa_ekpo
                key   = l_key1
                text  = l_node_text
                flag  = space
              CHANGING
                i_key = l_key2.
          ENDAT.
          CLEAR l_node_text.
          MOVE wa_ekpo-ebelp  TO l_node_text.
    * Call method for Add Node to Ekpo
          CALL METHOD add_node_ekpo
            EXPORTING
              table = wa_ekpo
              key   = l_key2
              text  = l_node_text
              flag  = 'X'
            CHANGING
              i_key = l_key3.
        ENDLOOP.                                     " LOOP AT i_ekpo  INTO  wa_ekpo1.
    * Call method For Register events
        CALL METHOD register_events_ekpo.
      ENDMETHOD.                                     " Display_ekpo
    * Display VBAP                                                       *
      METHOD  display_vbap.
    *  Data
        DATA:
           l_key1 TYPE lvc_nkey,
           l_key2 TYPE lvc_nkey,
           l_key3 TYPE lvc_nkey,
           l_node_text TYPE lvc_value.
        REFRESH i_fcat_vbap.
    * ALV control service modules
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_buffer_active        = 'X'
            i_structure_name       = 'VBAP'
            i_client_never_display = 'X'
            i_bypassing_buffer     = space
          CHANGING
            ct_fieldcat            = i_fcat_vbap
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc EQ 0.
          DELETE i_fcat_vbap FROM 4.
        ENDIF.                                       " IF sy-subrc EQ 0.
        g_hierarchy_header-heading = 'Sales Order Details'(003).
        g_hierarchy_header-tooltip = 'Sales Order'(004).
        g_hierarchy_header-width = c_30.
        g_hierarchy_header-width_pix = ' '.
    * Display
        CALL METHOD tree2->set_table_for_first_display
          EXPORTING
            is_hierarchy_header = g_hierarchy_header
            is_variant          = g_variant
          CHANGING
            it_outtab           = obj_main->i_vbap_op
            it_fieldcatalog     = i_fcat_vbap.
        LOOP AT i_vbap  INTO  wa_vbap1.
          MOVE wa_vbap1 TO wa_vbap.
          l_key1  = ''.
          AT NEW  vbeln.
            MOVE wa_vbap-vbeln  TO l_node_text.
    * Call method for Add Node to vbap
            CALL METHOD add_node_vbap
              EXPORTING
                table = wa_vbap
                key   = l_key1
                text  = l_node_text
                flag  = 'X'
              CHANGING
                i_key = l_key2.
          ENDAT.
          CLEAR l_node_text.
          MOVE wa_vbap-posnr  TO l_node_text.
    * Call method for Add Node to vbap
          CALL METHOD add_node_vbap
            EXPORTING
              table = wa_vbap
              key   = l_key2
              text  = l_node_text
              flag  = space
            CHANGING
              i_key = l_key3.
        ENDLOOP.                                     " LOOP AT i_vbap  INTO  wa_vbap1.
    * Call method For Register events
        CALL METHOD register_events_vbap.
      ENDMETHOD.                                     " Display_vbap
    * Add Node to Ekko                                                   *
      METHOD  add_node_ekpo.
    * Data
        DATA: l_layout_node TYPE lvc_s_layn.
        IF flag = 'X'.
          l_layout_node-dragdropid = g_handle_drag.
        ENDIF.                                       " IF flag = 'X'.
    *   Add node to tree1
        CALL METHOD tree1->add_node
          EXPORTING
            i_relat_node_key     = key
            i_relationship       = cl_gui_column_tree=>relat_last_child
            is_outtab_line       = table
            i_node_text          = text
            is_node_layout       = l_layout_node
          IMPORTING
            e_new_node_key       = i_key
          EXCEPTIONS
            relat_node_not_found = 1
            node_not_found       = 2
            OTHERS               = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
      ENDMETHOD.                                     " Add_node_ekpo
    * Add Node to Vbap                                                   *
      METHOD  add_node_vbap.
    * Data
        DATA: l_layout_node TYPE lvc_s_layn.
        IF flag = 'X'.
          l_layout_node-dragdropid = g_handle_drop.
        ENDIF.                                       " IF flag = 'X'.
    * Add node for tree2
        CALL METHOD tree2->add_node
          EXPORTING
            i_relat_node_key     = key
            i_relationship       = cl_gui_column_tree=>relat_last_child
            is_outtab_line       = table
            i_node_text          = text
            is_node_layout       = l_layout_node
          IMPORTING
            e_new_node_key       = i_key
          EXCEPTIONS
            relat_node_not_found = 1
            node_not_found       = 2
            OTHERS               = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
      ENDMETHOD.                                     " Add_node_vbap
    * Dnd behaviour                                                      *
      METHOD  dnd_behaviour.
    * Data
        DATA: effect TYPE i,
              l_flavor TYPE c VALUE 'f'.
    * For drag
        CREATE OBJECT g_drag.
        effect = cl_dragdrop=>copy.
        CALL METHOD g_drag->add
          EXPORTING
            flavor         = l_flavor
            dragsrc        = 'X'
            droptarget     = ' '
            effect         = effect
            effect_in_ctrl = effect.
        CALL METHOD g_drag->get_handle
          IMPORTING
            handle = g_handle_drag.
    * For Drop
        CREATE OBJECT g_drop.
        effect = cl_dragdrop=>copy.
        CALL METHOD g_drop->add
          EXPORTING
            flavor         = l_flavor
            dragsrc        = ' '
            droptarget     = 'X'
            effect         = effect
            effect_in_ctrl = effect.
        CALL METHOD g_drop->get_handle
          IMPORTING
            handle = g_handle_drop.
      ENDMETHOD.                                     " Dnd_behaviour
    * register events                                                    *
      METHOD  register_events_ekpo.
    * Data
        DATA: lt_events TYPE cntl_simple_events.
    * Tree events registers ALV Tree
        CALL METHOD tree1->get_registered_events
          IMPORTING
            events = lt_events.
    * Register events on frontend
        CALL METHOD tree1->set_registered_events
          EXPORTING
            events                    = lt_events
          EXCEPTIONS
            cntl_error                = 1
            cntl_system_error         = 2
            illegal_event_combination = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
    * Event Handling
        SET HANDLER obj_main->handle_drag_multiple FOR tree1.
      ENDMETHOD.                                     " Register_events_ekpo
    * register events                                                    *
      METHOD  register_events_vbap.
    * Data
        DATA: lt_events TYPE cntl_simple_events.
    * Tree events registers ALV Tree
        CALL METHOD tree2->get_registered_events
          IMPORTING
            events = lt_events.
    * Register events on frontend
        CALL METHOD tree2->set_registered_events
          EXPORTING
            events                    = lt_events
          EXCEPTIONS
            cntl_error                = 1
            cntl_system_error         = 2
            illegal_event_combination = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
    * Event
        SET HANDLER obj_main->handle_drop FOR tree2.
      ENDMETHOD.                                     " Register_events_vbap
    * Handle drag multiple Values                                        *
      METHOD handle_drag_multiple.
    * Data
        DATA: dataobj       TYPE REF TO lcl_dragobj,
              l_node_key    TYPE lvc_nkey,
              l_ekpo        TYPE t_ekpo,
              l_node_text   TYPE lvc_value,
              l_node_layout TYPE lvc_s_layn.
    * Create and fill dataobject for event ON_DROP.
        CREATE OBJECT dataobj.
    * Loop the Node key Table
        LOOP AT node_key_table INTO l_node_key.
          CALL METHOD sender->get_outtab_line
            EXPORTING
              i_node_key     = l_node_key
            IMPORTING
              e_outtab_line  = l_ekpo
              e_node_text    = l_node_text
              es_node_layout = l_node_layout.
          IF l_node_layout-isfolder NE 'X'.
            dataobj->wa_node_info-l_node_key  = l_node_key.
            dataobj->wa_node_info-l_ekpo      = l_ekpo.
            dataobj->wa_node_info-l_node_text = l_node_text.
            APPEND dataobj->wa_node_info TO dataobj->i_node_info.
          ENDIF.                                     " IF l_node_layout-isfolder NE 'X'.
        ENDLOOP.                                     " LOOP AT node_key_table INTO l_node_key
        drag_drop_object->object = dataobj.
      ENDMETHOD.                                     " Handle_drag_multiple
    * Handle drop multiple Values                                        *
      METHOD handle_drop.
        DATA: dataobj TYPE REF TO lcl_dragobj,
              l_new_key TYPE lvc_nkey,
              l_node_text TYPE lvc_value.
        CATCH SYSTEM-EXCEPTIONS move_cast_error = 1.
    * ON_DROP
          dataobj ?= drag_drop_object->object.
          LOOP AT dataobj->i_node_info INTO dataobj->wa_node_info.
            MOVE dataobj->wa_node_info-l_node_text  TO l_node_text.
    * Call method for Add Node to vbap
            CALL METHOD add_node_drop
              EXPORTING
                table = dataobj->wa_node_info-l_ekpo
                key   = node_key
                text  = l_node_text
              CHANGING
                i_key = l_new_key.
          ENDLOOP.                                   " LOOP AT dataobj->i_node_info INTO dataobj->wa_node_inf
    * Expand the node
          CALL METHOD sender->expand_node
            EXPORTING
              i_node_key = node_key
          CALL METHOD sender->frontend_update.
        ENDCATCH.
        IF sy-subrc NE 0.
          CALL METHOD drag_drop_object->abort.
        ENDIF.                                       " IF sy-subrc NE 0
      ENDMETHOD.                                     " Handle_drop
    * Add Node to drop                                                   *
      METHOD  add_node_drop.
    * Add node to drop tree
        CALL METHOD tree2->add_node
          EXPORTING
            i_relat_node_key     = key
            i_relationship       = cl_gui_column_tree=>relat_last_child
            is_outtab_line       = table
            i_node_text          = text
    *       is_node_layout       = l_layout_node
          IMPORTING
            e_new_node_key       = i_key
          EXCEPTIONS
            relat_node_not_found = 1
            node_not_found       = 2
            OTHERS               = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0
      ENDMETHOD.                                     " Add_node_drop
    ENDCLASS.                                        " lcl_main IMPLEMENTATION
    *&      Module  STATUS_0100  OUTPUT
    *  Screen 100 Pbo
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'BACK'.
    *  SET TITLEBAR 'xxx'.
      CALL METHOD obj_main->build_display.
    ENDMODULE.                                       " Status_0100 OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *  Screen 100 Pai
    MODULE user_command_0100 INPUT.
      IF sy-ucomm EQ 'BACK'.
        LEAVE TO SCREEN 0.
      ENDIF.                                         " IF sy-ucomm EQ 'BACK'
    ENDMODULE.                                       " USER_COMMAND_0100  INPUT
    *& Report  ZBPS_TREE_DRAG_DROP
    REPORT  zbps_tree_drag_drop.
    *       CLASS lcl_main DEFINITION
    CLASS lcl_main  DEFINITION.
      PUBLIC SECTION.
    * Types
        TYPES:
                BEGIN OF  t_ekpo,
                  ebeln TYPE ebeln,
                  ebelp TYPE ebelp,
                END OF    t_ekpo.
        TYPES:
                BEGIN OF  t_vbap,
                  vbeln TYPE vbeln,
                  posnr TYPE vbelp,
                END OF    t_vbap.
    * Internal Tables
        DATA:
              i_ekpo        TYPE STANDARD TABLE OF t_ekpo,
              i_ekpo_op     TYPE STANDARD TABLE OF t_ekpo,
              i_vbap        TYPE STANDARD TABLE OF t_vbap,
              i_vbap_op     TYPE STANDARD TABLE OF t_vbap,
              i_fcat_ekpo   TYPE                   lvc_t_fcat,
              i_fcat_vbap   TYPE                   lvc_t_fcat.
    * Work Areas
        DATA:
              wa_ekpo   TYPE t_ekpo,
              wa_ekpo1  TYPE t_ekpo,
              wa_vbap   TYPE t_vbap,
              wa_vbap1  TYPE t_vbap.
    * Data Declarations
        DATA:
              g_ebeln TYPE ebeln,
              g_vbeln TYPE vbeln_va.
        DATA: g_variant          TYPE disvariant,
              g_hierarchy_header TYPE treev_hhdr,
              g_handle_drag      TYPE i,
              g_handle_drop      TYPE i.
    * Class data
        DATA:
              splitter    TYPE REF TO cl_gui_splitter_container,
              container   TYPE REF TO cl_gui_custom_container,
              container_1 TYPE REF TO cl_gui_container,
              container_2 TYPE REF TO cl_gui_container,
              tree1       TYPE REF TO cl_gui_alv_tree,
              tree2       TYPE REF TO cl_gui_alv_tree,
              g_drag      TYPE REF TO cl_dragdrop,
              g_drop      TYPE REF TO cl_dragdrop.
    * Constants
        CONSTANTS:
                  c_30(2) TYPE c VALUE '30'.
    * Methods
        METHODS:
                  get_data,                          " Data Fatch
                  build_display,                     " Display Container
                  display_ekpo,                      " Ekpo table display
                  display_vbap,                      " Vbap table display
                  add_node_ekpo                      " Add node to Ekpo
                    IMPORTING table  TYPE t_ekpo
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                              flag   TYPE c
                    CHANGING  i_key  TYPE lvc_nkey,
                  add_node_vbap                      " Add node to vbap
                    IMPORTING table  TYPE t_vbap
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                              flag   TYPE c
                    CHANGING  i_key  TYPE lvc_nkey,
                  dnd_behaviour,                     " Drag and drop behavour
                  register_events_ekpo,              " Register Events Ekpo
                  register_events_vbap,              " Register events vbap
                  handle_drag_multiple               " Drag Multiple Values
                     FOR EVENT on_drag_multiple
                     OF cl_gui_alv_tree
                     IMPORTING sender node_key_table fieldname drag_drop_object,
                  handle_drop                        " Drop the values
                     FOR EVENT on_drop
                     OF cl_gui_alv_tree
                     IMPORTING sender node_key drag_drop_object,
                  add_node_drop                      " Add node to Drop Node
                    IMPORTING table  TYPE t_ekpo
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                    CHANGING  i_key  TYPE lvc_nkey.
    ENDCLASS.                                        " Lcl_main DEFINITION
    *       CLASS LCL_DRAGOBJ DEFINITION
    * Drag And drop Structure
    CLASS lcl_dragobj DEFINITION INHERITING FROM lcl_main FINAL.
      PUBLIC SECTION.
    * Types
        TYPES: BEGIN OF t_node_info,
                  l_ekpo      TYPE t_ekpo,
                  l_node_text TYPE lvc_value,
                  l_node_key  TYPE lvc_nkey,
               END OF t_node_info.
    * Data
        DATA: i_node_info  TYPE TABLE OF t_node_info,
              wa_node_info TYPE t_node_info.
    ENDCLASS.                                        " LCL_DRAGOBJ DEFINITION
    * Object Declarations
    DATA  obj_main  TYPE REF TO lcl_main.
    * Initialization                                                     *
    INITIALIZATION.
      CREATE OBJECT obj_main.
    * Selection Screen                                                   *
      SELECTION-SCREEN  BEGIN OF BLOCK  block1  WITH FRAME.
      SELECT-OPTIONS:
                      s_ebeln FOR obj_main->g_ebeln,
                      s_vbeln FOR obj_main->g_vbeln MATCHCODE OBJECT  cs_vbeln.
      SELECTION-SCREEN  END OF   BLOCK  block1.
    * Start of Selection                                                 *
    START-OF-SELECTION.
    * Call Screen
      CALL SCREEN 100.
    *       CLASS lcl_main IMPLEMENTATION
    * Local class Implementation
    CLASS lcl_main  IMPLEMENTATION.
    * Get Data                                                           *
      METHOD  get_data.
    * Data from Ekpo
        SELECT  ebeln
                ebelp
          FROM  ekpo
          UP TO 100 ROWS
          INTO  TABLE i_ekpo
         WHERE  ebeln IN  s_ebeln.
    * Data from Vbap
        SELECT  vbeln
                posnr
          FROM  vbap
          UP TO 100 ROWS
          INTO  TABLE i_vbap
         WHERE  vbeln IN  s_vbeln.
      ENDMETHOD.                                     " Get_data
    * Build Display                                                      *
      METHOD  build_display.
    * Create Container
        CREATE OBJECT container
          EXPORTING
            container_name = 'CUST_CONT'.
    * Split the container
        CREATE OBJECT splitter
          EXPORTING
            parent  = container
            rows    = 1
            columns = 2.
        CALL METHOD splitter->get_container
          EXPORTING
            row       = 1
            column    = 1
          RECEIVING
            container = container_1.
        CALL METHOD splitter->get_container
          EXPORTING
            row       = 1
            column    = 2
          RECEIVING
            container = container_2.
    * create tree control
        CREATE OBJECT tree1
          EXPORTING
            parent                      = container_1
            node_selection_mode         = cl_gui_column_tree=>node_sel_mode_multiple
            item_selection              = 'X'
            no_html_header              = 'X'
            no_toolbar                  = 'X'
          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.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
        CREATE OBJECT tree2
          EXPORTING
            parent                      = container_2
            node_selection_mode         = cl_gui_column_tree=>node_sel_mode_multiple
            item_selection              = 'X'
            no_html_header              = 'X'
            no_toolbar                  = 'X'
          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.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
        g_variant-report      = sy-repid.
        g_variant-handle      = space.
        g_variant-log_group   = space.
        g_variant-username    = space.
        g_variant-text        = space.
        g_variant-dependvars  = space.
    * Call method for get data
        CALL METHOD get_data.
    * Drap And Drop behaviour method
        CALL METHOD dnd_behaviour.
    * Display the Ekpo table
        CALL METHOD obj_main->display_ekpo.
    * Diaplay the vbap table
        CALL METHOD obj_main->display_vbap.
        CALL METHOD tree1->frontend_update.
        CALL METHOD tree2->frontend_update.
      ENDMETHOD.                                     " Build_display
    * Display EKPO                                                       *
      METHOD  display_ekpo.
    * Data
        DATA:
              l_key1 TYPE lvc_nkey,
              l_key2 TYPE lvc_nkey,
              l_key3 TYPE lvc_nkey,
              l_node_text TYPE lvc_value.
    * ALV control service modules
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_buffer_active        = 'X'
            i_structure_name       = 'EKPO'
            i_client_never_display = 'X'
            i_bypassing_buffer     = space
          CHANGING
            ct_fieldcat            = i_fcat_ekpo
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc EQ 0.
          DELETE i_fcat_ekpo FROM 4.
        ENDIF.                                       " IF sy-subrc EQ 0.
        g_hierarchy_header-heading = 'Purchase Order Details'(001).
        g_hierarchy_header-tooltip = 'Purchase Order'(002).
        g_hierarchy_header-width = c_30.
        g_hierarchy_header-width_pix = ' '.
    * Diaply
        CALL METHOD tree1->set_table_for_first_display
          EXPORTING
            is_hierarchy_header = g_hierarchy_header
            is_variant          = g_variant
          CHANGING
            it_outtab           = obj_main->i_ekpo_op
            it_fieldcatalog     = i_fcat_ekpo.
        LOOP AT i_ekpo  INTO  wa_ekpo1.
          MOVE wa_ekpo1 TO wa_ekpo.
          l_key1  = ''.
          AT NEW  ebeln.
            MOVE wa_ekpo-ebeln  TO l_node_text.
    * Call method for Add Node to Ekpo
            CALL METHOD add_node_ekpo
              EXPORTING
                table = wa_ekpo
                key   = l_key1
                text  = l_node_text
                flag  = space
              CHANGING
                i_key = l_key2.
          ENDAT.
          CLEAR l_node_text.
          MOVE wa_ekpo-ebelp  TO l_node_text.
    * Call method for Add Node to Ekpo
          CALL METHOD add_node_ekpo
            EXPORTING
              table = wa_ekpo
              key   = l_key2
              text  = l_node_text
              flag  = 'X'
            CHANGING
              i_key = l_key3.
        ENDLOOP.                                     " LOOP AT i_ekpo  INTO  wa_ekpo1.
    * Call method For Register events
        CALL METHOD register_events_ekpo.
      ENDMETHOD.                                     " Display_ekpo
    * Display VBAP                                                       *
      METHOD  display_vbap.
    *  Data
        DATA:
           l_key1 TYPE lvc_nkey,
           l_key2 TYPE lvc_nkey,
           l_key3 TYPE lvc_nkey,
           l_node_text TYPE lvc_value.
        REFRESH i_fcat_vbap.
    * ALV control service modules
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_buffer_active        = 'X'
            i_structure_name       = 'VBAP'
            i_client_never_display = 'X'
            i_bypassing_buffer     = space
          CHANGING
            ct_fieldcat            = i_fcat_vbap
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc EQ 0.
          DELETE i_fcat_vbap FROM 4.
        ENDIF.                                       " IF sy-subrc EQ 0.
        g_hierarchy_header-heading = 'Sales Order Details'(003).
        g_hierarchy_header-tooltip = 'Sales Order'(004).
        g_hierarchy_header-width = c_30.
        g_hierarchy_header-width_pix = ' '.
    * Display
        CALL METHOD tree2->set_table_for_first_display
          EXPORTING
            is_hierarchy_header = g_hierarchy_header
            is_variant          = g_variant
          CHANGING
            it_outtab           = obj_main->i_vbap_op
            it_fieldcatalog     = i_fcat_vbap.
        LOOP AT i_vbap  INTO  wa_vbap1.
          MOVE wa_vbap1 TO wa_vbap.
          l_key1  = ''.
          AT NEW  vbeln.
            MOVE wa_vbap-vbeln  TO l_node_text.
    * Call method for Add Node to vbap
            CALL METHOD add_node_vbap
              EXPORTING
                table = wa_vbap
                key   = l_key1
                text  = l_node_text
                flag  = 'X'
              CHANGING
                i_key = l_key2.
          ENDAT.
          CLEAR l_node_text.
          MOVE wa_vbap-posnr  TO l_node_text.
    * Call method for Add Node to vbap
          CALL METHOD add_node_vbap
            EXPORTING
              table = wa_vbap
              key   = l_key2
              text  = l_node_text
              flag  = space
            CHANGING
              i_key = l_key3.
        ENDLOOP.                                     " LOOP AT i_vbap  INTO  wa_vbap1.
    * Call method For Register events
        CALL METHOD register_events_vbap.
      ENDMETHOD.                                     " Display_vbap
    * Add Node to Ekko                                                   *
      METHOD  add_node_ekpo.
    * Data
        DATA: l_layout_node TYPE lvc_s_layn.
        IF flag = 'X'.
          l_layout_node-dragdropid = g_handle_drag.
        ENDIF.                                       " IF flag = 'X'.
    *   Add node to tree1
        CALL METHOD tree1->add_node
          EXPORTING
            i_relat_node_key     = key
            i_relationship       = cl_gui_column_tree=>relat_last_child
            is_outtab_line       = table
            i_node_text          = text
            is_node_layout       = l_layout_node
          IMPORTING
            e_new_node_key       = i_key
          EXCEPTIONS
            relat_node_not_found = 1
            node_not_found       = 2
            OTHERS               = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
      ENDMETHOD.                                     " Add_node_ekpo
    * Add Node to Vbap                                                   *
      METHOD  add_node_vbap.
    * Data
        DATA: l_layout_node TYPE lvc_s_layn.
        IF flag = 'X'.
          l_layout_node-dragdropid = g_handle_drop.
        ENDIF.                                       " IF flag = 'X'.
    * Add node for tree2
        CALL METHOD t

  • Drag and Drop nodes in JTree

    Is there a way to drap and drop JTree nodes without resorting to hacks? http://www.javaworld.com/javatips/jw-javatip97.html outlines a hack to get drag and drop working but it is kinda old. I am wondering whether there is a now a way to do this in Swing. http://weblogs.java.net/blog/shan_man/archive/2006/01/first_class_dra.html outlines a seemingly promising way but when I tried it it still wouldn't let me drag JTree nodes. (btw, if you are going to try it, you must replace TransferHandler.TransferInfo with TransferHandler.TransferSupport. It has apprently been renamed.)

    I have implemented drag and drop of nodes in JTree they same way it is explained in JavaWorld link that you mentioned, I customized it for my application and it worked great.

  • How to Drag and drop Mail message in Calendar event in Yosemite

    Hi,
      I am not sure if this has already been answered or if Yosemite Mail is missing one cool feature. In Mavericks and before, it was every easy to drap and drop a email message to a calendar event in the "URL" attachment section where it appeared as "Show in Mail..." in the event. But now, I don't find this drap-and-drop feature anymore?
    The other alternative is to create a event from the Mail message content if there is a date (like 12/12/14) specified. But what about messages which do not have dates in them but I still want to attach the email to a calendar event?
    Please chime in if others are also experiencing the same pain in Yosemite or if there is any other easier trick?
    Thanks!

    Hi Vivman,
    You have duplicated this post here. Please do not post the same question to separate forum post.
    Cheers.
    | Michael K | Project Manager | LabVIEW R&D | National Instruments |

  • Drag and Drop in Web dynpro ALV

    I have a requirement in wda where I am supposed to select few records from source table and drop it in target table. The dropped records should be inserted at the right index /destination, dropped at.  I see SAP examples but they are all associated with tables and none of them are ALV grids.
    Could anyone of you please share steps or code to achieve drap and drop in SALV_WD_TABLE.

    Hi Kiran,
    I am in 703 so drag and drop should work good .
    I am required to drag and drop records from ALV1(bottom) to ALV2(top) (and not table UI). I could create drag source but somehow the whole piece is not working .
    Drop target field is dynamic. Wherever the user drops, the data in ALV2 should be inserted/updated exactly at that spot/cell . Here, I am not sure how to fill target row/field details runtime.
    Just to simplify, I am doing 1 column move. Hard coded the target field ‘AUFNR3’ but still than My “On drop event” is not triggering. I always see a prohibitory sign when trying to move the ghost image across areas as if the column is not defined as DropTarget.
    My code looks something like this:
    Drop from AUFNR of ALV2 to AUFNR3 of ALV1 :
    In WDDOINIT:*...get alv models
      lr_dd_alv1 ?= wd_this->r_model_calen.
      lr_dd_alv2 ?= wd_this->r_model_operlist.
    l_tags_alv2 = 'AUFNR'.* create or enable/disable alvs as drag source
      IF NOT lr_dd_alv2->r_drag_source_info IS BOUND.
        lr_dd_alv2->create_drag_source_info(
          EXPORTING
            data = 'ALV2'
            tags = l_tags_alv2 "'alv2'
            enabled = abap_true ).
      ELSE.
        lr_dd_alv2->r_drag_source_info->set_enabled( abap_true ).
      ENDIF.
    l_tags_alv1 = 'AUFNR3'.
      lr_dd_alv1->set_drop_row_name_fieldname( 'AUFNR3' ).
      lr_dd_alv1->set_drop_row_name( ' ' ).
      lr_dd_alv1->create_drop_row_target_info(
        EXPORTING
          id   = 'ALV1'
          name = 'alv1'
          tags = l_tags_alv1
          enabled = abap_true ).
    In drop event: I am trying to fetch the selected row and update the ALV2 accordingly
    lr_element = lr_node->get_lead_selection( ).
      IF lr_element IS BOUND.
        lr_element->get_attribute(
            EXPORTING
              name = 'AUFNR'
            IMPORTING
              value = l_value ).
      ENDIF.
        lo_nd_nd_calendar = wd_context->get_child_node( name = wd_this->wdctx_nd_calendar ).
      lo_nd_nd_calendar->bind_table( new_items = lt_nd_calendar set_initial_elements = abap_true ).
    ENDMETHOD.
    Any help is greatly appreciated..

  • SAPGUI scripting recording cause alv component drag and drop not work

    Hi all:
       after I started recording, and the drap and drop behavior of ALV tree component not work at once,
      any body has any idea or workround?
    Thanks
    Michael

    This problem has been asked in a couple of threads without any response.
    Similar to other folks, I have a page with a list orders. The list of the orders is displayed using the new basic Table component. User goes to a certain page. Then the user clicks the detail button column to lookup details of the order. When the user closes the details page he/she obviously needs to return to the same.
    Each time the user clicks the details button I get the current first row number, let's call it currentFirst, by using tableRowGroup1.getFirst() and save it in the session bean.
    When I return to the list of the order page, I am trying to use the suggested method tableRowGroup1.setFirst(currentFirst). I am using this method in the prerender() method. The problem is that when Creator displays the page the first time, the tableRowGroup1 does not seem to be bound to the respective provider yet. All attributes of the tableRowGroup1are equal either to zero or null. Therefore, as the debugger shows, tableRowGroup1.setFirst(currentFirst) does affect anything. Binding happens after the prerender method and I don't see anyway to intervene. Creator always displays the first page of the table on return from previous web page.
    I was also trying to set provider's cursor. I've checked in the debugger that I've set the cursor to the required row, but Creator still displays the first page of the table on return from previous web page.
    Any help would be greatly appreciated!
    Thanks
    Slava

Maybe you are looking for