Add multiple elements to a tree control at once
I am using a Tree Control to display customer and certificate information. However, adding 500 customer names or certificate numbers to the tree control one at a time takes for ever (well, 30000 ms). Is there any way to add multiple elements to a tree all at once, or is the only solution to use a listbox with 'forward' and 'back' buttons ?
thanks,
michael
Hi Michael
I don’t believe there is a way to supply a list of child items to a parent item, they have to be added incrementally. One way that you could speed this process up is to design your code such that only when you expand an item does it add the child items.
If you want an even higher update rate have a look at using the ActiveX TreeView control, you will find an example called Family Tree.vi in the LV examples.
I'll do up some code that makes using both of the controls more efficient if enough people want it.
Kurt Friday
www.sciware.com.au
Similar Messages
-
Can I add multiple elements on a single line?
Can I add multiple elements on a single line?
Not yet. But this is something we plan to support. You can vote on this idea here: http://forums.adobe.com/ideas/1046
We use this to help prioritize our work.
Randy -
How to avoid multiple selection in ALV tree control?
Hi,
Experts,
I want to avoid multiple selections on Alv tree control after pressing control keyboard button(Ctrl). Even by pressing Ctrl keyword button i want to select only one row of a Alv tree control.i have used cl_salv_tree class for it is there any method to achieve this please pass some code/idea on it.
Thanks in advance,
Shabeer ahmed.I haven't tried it before but it should help.
[https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01] -
Add multiple elements in response using rules
All,
I am very interested to know if anyone can tell me how I can add multiple elements in the response using the rules engine in oracle SOA 11g (version 11.1.1.3).
For every rule that fires I want to add a complex element named Rule which contains the elements code and description of the rule fired. This information should be returned in the response.
I hope somebody has the answer.
Many Thanks
RenAll,
Please see below forum for an answer:
Re: Unbounded element in Business Rules
Regards,
Ren -
Is there a way to add multiple agents to a skill group at once?
Hi All,
Is there a way to add multiple agents to a skill group at once by using bulk edit or some other means?
I am using ICM 8.0
Thanks in advance.Hi Piyush,
There is a tricky way of doing it in the config manager. Say for example, if you have 100 agents to be added, rename the agent so that they get listed first while adding to the skill group. This will reduce the effort of searching the agents. You can scroll and select the total number of agents till it is renamed and revert back once added to the skill groups
Hope this helps
Cheers,
Dass
Please rate useful posts -
Single click on tree control navigation
Hello I have a tree control where I have include the navigation, I know that there is a method
HANDLE_NODE_DOUBLE_CLICK FOR G_TREE
but is there an method for only one click, I want to change my alv grid data when I click on several nodes in my tree controlHello Muhammet
I have re-written my sample report ZUS_SDN_TWO_ALV_GRIDS into ZUS_SDN_TREE_AND_GRID_CONTROL which is now display a tree control together with the ALV grid.
When you analyze this new report you will see that every step of the program logic is as I described in my previous e-mails.
*& Report ZUS_SDN_TWO_ALV_GRIDS
*& Screen '0100' contains no elements.
*& ok_code -> assigned to GD_OKCODE
*& Flow logic:
* PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
* PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
*& Thread: single click on tree control navigation
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1143770"></a>
REPORT zus_sdn_tree_and_grid_control.
TYPE-POOLS: abap, cntl.
TYPES: node_table_type LIKE STANDARD TABLE OF mtreesnode
WITH DEFAULT KEY.
* CAUTION: MTREESNODE is the name of the node structure which must
* be defined by the programmer. DO NOT USE MTREESNODE!
CONSTANTS:
BEGIN OF c_nodekey,
root TYPE tv_nodekey VALUE 'Root', "#EC NOTEXT
child1 TYPE tv_nodekey VALUE 'Child1', "#EC NOTEXT
* child2 type tv_nodekey value 'Child2', "#EC NOTEXT
new1 TYPE tv_nodekey VALUE 'New1', "#EC NOTEXT
new2 TYPE tv_nodekey VALUE 'New2', "#EC NOTEXT
* new3 type tv_nodekey value 'New3', "#EC NOTEXT
* new4 type tv_nodekey value 'New4', "#EC NOTEXT
END OF c_nodekey.
DATA:
gd_okcode TYPE ui_func,
gd_repid TYPE syst-repid,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_cell_left TYPE REF TO cl_gui_container,
go_cell_right TYPE REF TO cl_gui_container,
go_tree TYPE REF TO cl_gui_simple_tree,
go_grid1 TYPE REF TO cl_gui_alv_grid,
** go_grid2 TYPE REF TO cl_gui_alv_grid,
gs_layout TYPE lvc_s_layo.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1,
gt_knvv TYPE STANDARD TABLE OF knvv.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_knb1 TYPE knb1.
CHECK ( sender = go_grid1 ).
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
** CALL METHOD go_grid1->set_current_cell_via_id
** EXPORTING
*** IS_ROW_ID =
*** IS_COLUMN_ID =
** is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
* CLASS LCL_APPLICATION DEFINITION
CLASS lcl_application DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
md_event TYPE string READ-ONLY,
md_node_key TYPE tv_nodekey READ-ONLY.
CLASS-METHODS:
handle_node_double_click
FOR EVENT node_double_click
OF cl_gui_simple_tree
IMPORTING node_key,
handle_expand_no_children
FOR EVENT expand_no_children
OF cl_gui_simple_tree
IMPORTING node_key.
ENDCLASS. "LCL_APPLICATION DEFINITION
* CLASS LCL_APPLICATION IMPLEMENTATION
CLASS lcl_application IMPLEMENTATION.
METHOD handle_node_double_click.
" this method handles the node double click event of the tree
" control instance
" show the key of the double clicked node in a dynpro field
md_event = 'NODE_DOUBLE_CLICK'.
md_node_key = node_key.
" Trigger PAI and set ok-code = 'DETAIL'
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'DETAIL'
* IMPORTING
* rc =
MESSAGE md_node_key TYPE 'I'.
ENDMETHOD. "HANDLE_NODE_DOUBLE_CLICK
METHOD handle_expand_no_children.
" this method handles the expand no children event of the tree
" control instance
DATA: node_table TYPE node_table_type,
node TYPE mtreesnode.
" show the key of the double clicked node in a dynpro field
md_event = 'EXPAND_NO_CHILDREN'.
md_node_key = node_key.
IF node_key = 'Child1'.
* add two nodes to the tree control (the children of 'Child1')
* Node with key 'New1'
CLEAR node.
node-node_key = c_nodekey-new1.
node-relatkey = c_nodekey-child1.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-isfolder = ' '.
node-text = 'New1'(ne1).
APPEND node TO node_table.
* Node with key 'New2'
CLEAR node.
node-node_key = c_nodekey-new2.
node-relatkey = c_nodekey-child1.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-n_image = '@10@'.
node-expander = ' '.
node-text = 'New2'(ne2).
APPEND node TO node_table.
CALL METHOD go_tree->add_nodes
EXPORTING
table_structure_name = 'MTREESNODE'
node_table = node_table
EXCEPTIONS
failed = 1
error_in_node_table = 2
dp_error = 3
table_structure_name_not_found = 4
OTHERS = 5.
IF sy-subrc <> 0.
** MESSAGE A000.
ENDIF.
ENDIF.
ENDMETHOD. "HANDLE_EXPAND_NO_CHILDREN
ENDCLASS. "LCL_APPLICATION IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1 UP TO 100 ROWS
WHERE bukrs = '1000'.
PERFORM init_controls.
* Display data
gs_layout-grid_title = 'Customers: Sales Areas'.
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNVV'
is_layout = gs_layout
CHANGING
it_outtab = gt_knvv
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
* SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
CALL METHOD go_grid1->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
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.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
TRANSLATE gd_okcode TO UPPER CASE.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
* User has pushed button "Display Details"
WHEN 'DETAIL'.
MESSAGE gd_okcode TYPE 'I'.
PERFORM entry_show_details.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form ENTRY_SHOW_DETAILS
* text
* --> p1 text
* <-- p2 text
FORM entry_show_details .
* define local data
DATA:
ld_row TYPE i,
ls_knb1 TYPE knb1.
IF ( gt_knvv IS INITIAL ).
SELECT * FROM knvv INTO TABLE gt_knvv
FOR ALL ENTRIES IN gt_knb1
WHERE kunnr = gt_knb1-kunnr.
ELSE.
REFRESH: gt_knvv.
ENDIF.
ENDFORM. " ENTRY_SHOW_DETAILS
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 1
columns = 2
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_left.
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = go_cell_right.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_right
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_double_click FOR go_grid1.
PERFORM create_and_init_tree.
ENDFORM. " INIT_CONTROLS
*& Form CREATE_AND_INIT_TREE
* text
* --> p1 text
* <-- p2 text
FORM create_and_init_tree .
DATA: lt_node_table TYPE node_table_type,
lt_events TYPE cntl_simple_events,
ls_event TYPE cntl_simple_event.
* create a tree control
CREATE OBJECT go_tree
EXPORTING
parent = go_cell_left
node_selection_mode = cl_gui_simple_tree=>node_sel_mode_single " single node selection is used
EXCEPTIONS
lifetime_error = 1
cntl_system_error = 2
create_error = 3
failed = 4
illegal_node_selection_mode = 5.
IF sy-subrc <> 0.
** MESSAGE a000.
ENDIF.
* define the events which will be passed to the backend
" node double click
ls_event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
** ls_event-appl_event = 'X'. " process PAI if event occurs
" NOTE: Do NOT register as application event !!!!!
APPEND ls_event TO lt_events.
CALL METHOD go_tree->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc <> 0.
** MESSAGE a000.
ENDIF.
SET HANDLER:
lcl_application=>handle_node_double_click FOR go_tree,
lcl_application=>handle_expand_no_children FOR go_tree.
* add some nodes to the tree control
* NOTE: the tree control does not store data at the backend. If an
* application wants to access tree data later, it must store the
* tree data itself.
PERFORM build_node_table USING lt_node_table.
* node_table_structure_name = 'MTREESNODE'
* A programmer using the tree control must create a structure in the
* dictionary. This structure must include the structure TREEV_NODE
* and must contain a character field with the name 'TEXT'.
CALL METHOD go_tree->add_nodes
EXPORTING
table_structure_name = 'MTREESNODE'
node_table = lt_node_table
EXCEPTIONS
failed = 1
error_in_node_table = 2
dp_error = 3
table_structure_name_not_found = 4
OTHERS = 5.
IF sy-subrc <> 0.
** MESSAGE a000.
ENDIF.
ENDFORM. " CREATE_AND_INIT_TREE
*& Form build_node_table
* text
* --> p1 text
* <-- p2 text
FORM build_node_table
USING
node_table TYPE node_table_type.
DATA: node LIKE mtreesnode.
* Build the node table.
* Caution: The nodes are inserted into the tree according to the order
* in which they occur in the table. In consequence, a node must not
* occur in the node table before its parent node.
* Node with key 'Root'
node-node_key = c_nodekey-root.
" Key of the node
CLEAR node-relatkey. " Special case: A root node has no parent
CLEAR node-relatship. " node.
node-hidden = ' '. " The node is visible,
node-disabled = ' '. " selectable,
node-isfolder = 'X'. " a folder.
CLEAR node-n_image. " Folder-/ Leaf-Symbol in state "closed":
" use default.
CLEAR node-exp_image. " Folder-/ Leaf-Symbol in state "open":
" use default
CLEAR node-expander. " see below.
node-text = 'Root'(roo).
APPEND node TO node_table.
* Node with key 'Child1'
node-node_key = c_nodekey-child1.
" Key of the node
" Node is inserted as child of the node with key 'Root'.
node-relatkey = c_nodekey-root.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-hidden = ' '.
node-disabled = ' '.
node-isfolder = 'X'.
CLEAR node-n_image.
CLEAR node-exp_image.
node-expander = 'X'. " The node is marked with a '+', although
" it has no children. When the user clicks on the
" + to open the node, the event
" expand_no_children is fired. The programmer can
" add the children of the
" node within the event handler of the
" expand_no_children event
" (see method handle_expand_no_children
" of class lcl_application)
node-text = 'Child1'(ch1).
node-style = cl_gui_simple_tree=>style_emphasized_positive.
APPEND node TO node_table.
ENDFORM. " build_node_table
Regards
Uwe -
How can I save the all the values of a tree control ?
I have a problem, in run time, I adds new items on a tree control, but i don´t know how I can save the values of the child text of each item in a file.
Thanks.I'm no expert on the tree control, but I made a small example to save all items to a textfile, including item tag, item string, and indent level. One drawback of this method is that it fully expands the tree regardless how the user left it. To go the other direction, you'd have to write a routine to go through the text file and programmatically build the tree.
To master the tree control, I think you have to resort to creating a control reference for it and using the Invoke Node to do some operations. For another approach to traversing and operating on a tree, check out the "Traversing Tree Controls and Setting Custom Symbols" (search the NI Developer Zone site).
Best of luck,
John
Attachments:
Save Tree Structure to Textfile.vi 32 KB -
How to get access to Row Data (Child Text) in a Tree Control Pragmatically?
In LabVIEW 2010, I have entered Row Data into a Tree Control pragmatically using the Add Item method and providing the Child Text array and the Child Tag for the Row. When a Row in the Tree Control is selected, I can get the Row Tag in the Value Property of the Tree. But how do I access the Child Text array data when the Row is selected? I can't seem to find a Tree Control Property or Method that will return that data back again.
What I am trying to do is: once a Row in a Tree is selected and a button is pushed, if the Row Tag is valid, I want to transfer all of the Row data into another similarly formatted Tree. To do that I need the Row Data for the Tree and Row that was selected. I can not find a way to get access to this Row Data after it has been entered into the Tree.
Can anyone tell me how to pragmatically access the Child Text or Row Data in a Tree Control from a selected Row in the Tree? I have the Tag for the Row, but how do I access the data?
Thanks for your assistance.
Solved!
Go to Solution.As mentioned in the posting here, you can use the Active Item:Tag property to set the item to which subsequent property changes apply. This includes pulling the Active Celltring values out in a for loop as you increment the Active Cell:Active Column Number to get the row's Child Text data programmatically as I was originally wanting to do.
Note that wiring a 0 to the ActiveColNum property and reading the String value will return the tree item's visible name (in column 0), but not the unique item Tag (which is somewhat intangible after its creation). Therefore, I save the unique item tag when I add the item to the tree control (the output of the Add Item invoke node) and store it as a separate column of the Child Text array and place it out of sight in the tree control so I have access to it later. It might be useful, it might not.
I find the tree control totally non-intuitive and not well explained anywhere, but that's how a lot of LabVIEW coding is I guess. Play with it long enough and you become an expert. I had to learn the hard way, but I hope this helps someone else.
-Richard
"Computers are useless. They can only give you answers." - Pablo Picasso -
Hi,
i need to add a picture on the tree control. i have attached a image file for reference. i need to bring a tree control of that form. Can some one help me to achieve it.
Padhu
Attachments:
Tree Picture.jpg 10 KBsee here
Vix
In claris non fit interpretatio
Using LV 2013 SP1 on Win 7 64bit
Using LV 8.2.1 on WinXP SP3
Using CVI 2012 SP1 on Win 7 64bit, WinXP and WinXP Embedded
Using CVI 6.0 on Win2k, WinXP and WinXP Embedded -
Tree slow and bug with Add Multiple Items to End
Hello,
I use "Add Multiple Items to End" to fill a tree quickly in Labview 8.5.
In my test example, It's possible to choise an array of 100, 255 or 1000. parents.
Each parent has 10 children
100 is correctly, 255 is slowly an 1000 is big bug !
Y does a solution, or it has Labview major weaknesses with the function tree.
Thanks for you help.
A. Carbonnel
AC
Attachments:
Load Tree.vi 37 KBHere is the response of France rupport labview
Sir,
The behavior you observed beyond 1000 elements vi Tree is a known bug of R & D LabVIEW. Pending that it is corrected in a future version, I invite you to use the ActiveX Treeview. He should be able to meet your expectations in terms of number of elements.
You can see an example of the use of the ActiveX in attachments.
Sincerely,
AC
Attachments:
Tree view.zip 48 KB -
How do I add multiple photos to mission control for my desktop?
How do I add multiple photos to my desktop thru mission control. I have a 5 year old 23" iMac.
Of course you can add multiple photos from then Mail app but you can select multiple photos at once in the Photos app
-
How to add popupMenu to Tree control in BSP
Hello,
I need to attach a popupMenu HTMLB control to htmlb:tree control in BSP (something like a hooverMenu in EP).
Any ideas?
Thanks,
Yani'm using this code:
jTable1.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
int row = jTable1.rowAtPoint(e.getPoint());
int col = jTable1.columnAtPoint(e.getPoint());
pop.show(e.getComponent(), e.getX(), e.getY());
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
int sel = jTable1.rowAtPoint(e.getPoint());
int col = jTable1.columnAtPoint(e.getPoint());
pop.show(e.getComponent(), e.getX(), e.getY());
in the specified cell ( the cell i clicked) should be a vector with values. How can i get this vector and add the values to the popupMenu??
thanks
angela -
Tree control erroneously displays nodes multiple times
I'm attempting to use a Tree control to display some data.
I'm using an HierarchicalCollectionView as the dataProvider. All
the data displays, but it appears on the wrong level. For instance,
on the root level, it displays the root node (correctly marked with
the folder icon as having children), plus all the children (on the
root level!) If I expand the root node, underneath it it displays
its children as expected -- now there are 2 copys of all the
children, one in the correct place and one at the root level. If I
expand 2nd-level nodes, their children (and children's children,
etc) display underneath them... the pattern continues. It looks
like every level of the hierarchy displays ALL the nodes underneath
it, no matter how many levels down.
I think I know why this happens: a
HierarchicalCollectionView's createCursor() function returns an
IViewCursor that treats the collection as linear instead of
hierarchical. The Tree then uses this cursor to visit every node in
the tree, displaying it. When expanding a node, it again uses one
of these linear-type cursors, but on the children of the node
clicked on, so it displays all the children underneath it and their
children, etc. This seems like a major bug in the library -- I'm
pretty sure this isn't a problem with my code. Doesn't it seem
natural to use a HierarchicalCollectionView with a Tree control?
Has no one else ever experienced this issue? I'd expect it to work,
especially since HierarchicalCollectionView extends
ICollectionView, which is what the dataProvider wants. I've looked
through the source of the Tree class (and List, and ListBase) and I
think it all boils down to not using the dataDescriptor's
getChildren() method and instead using createCursor() directly on
the dataProvider. The dataDescriptor's getChildren() method returns
an ICollectionView that correctly only contains the next-level
nodes, not all of the ones all the way to the bottom of the
hierarchy. I think the bad behavior is inherited from ListBase (and
in that class, it actually makes sense... too bad nobody overrode
it in Tree).
Am I wrong? Am I making a mistake somewhere in my code? If
not, is there a workaround? Has a bug report been filed, and should
I file one if this is indeed a bug? Any help or insight would be
greatly appreciated.OK, after banging my head against this for a day and a half,
I finally have an answer. It seems that the problem is my root node
(and possibly others; I didn't delve that deep) is "open". I guess
something, somewhere is calling
IHierarchicalCollectionView.openNode() on it. Closing the node(s)
makes the problem disappear. I've attached a reproduction script
that's about as simple as I can make it (I guess it could be
simpler with less data, but oh well). Why does this happen? Should
I open a bug report? It seems to me that the correct behavior would
be to have the open node(s) disclosure controls start out open
rather than incorrectly displaying their children as on the same
level as them. -
How do I get the tag of a selected line in a tree control ?
I am running LabVIEW 7.1.
I want to be able to add a parent or sibling to a tree to a selected item in a tree.The tag of the selected item is actually the output of the tree control itself. If you create an indicator from the tree control, you will get a duplicate tree control (indicator), but if you wire the output into a string indicator, the tag of the selected item will show up. You can an item to the tree by wiring the tree reference into an invoke node, calling the method "Edit Tree Items: Add Item", and wiring the output of the tree control (which will be the tag of the selected item) into the "Parent Tag" terminal. This method will only let you add a child to an item, you cannot add a parent or sibling. Items cannot have multiple parents, so it wouldn't make sense to add a parent; and to add a sibling for the selected item, you could call the method "Navigate Tree: Get Parent" and pass the tag of the parent into the "Edit Tree Items: Add Item" method.
Robert Mortensen
Software Engineer
National Instruments -
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,
ArunOnce 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
Maybe you are looking for
-
Hi, Using Pivot query i have generated Process in below format. RefNo Part Process1 Process2 Process3 1 A 20 15 15 2 B 10 10 10 3 B 5 5 5 4 c 10 9 9 5 b 20 19 19 I want to add Start time and End time for each Process. Like RefNo Part Process1 Startt
-
JDeveloper settings - change the default code editor view for JSPx files
Hi, when you open a .JSPX or JSP page the editor opens in 'design' mode. Is there a way to change this default behavior and open in 'source' mode? I write the JSF/JSP pages editing code and every time I open a new page I have to wait till the IDE ope
-
Hi, I have a page where you scan a barcode into a text field submits when enter pressed. If the barcode exists a report appears showing that record. The barcode must stay in the text field. My question is if I scan a barcode and the barcode does not
-
hello and thanks for reading i was earsing my phone to start over and it got stuck on a loop werethe phone starts and then goes back the apple logo does anybody know a soultion
-
I live in an appartment and Have other people living on almost all sides of me. Someone has an apple remote that is continuoisly changing the volume on my computer and hiting "play" or "pause" on things and it's getting really annoying. How can I mak