JTreeTable - advance probelms? puting into tree a JCheckBox
I carefuly read the example in the Swing Connection but the problem is as such presently i modified the component to view the tree in the Table with the aditional column named Selected) but the finla version is as such i would like to put JCheckBox into the tree component vied in the Table. So far I achieved it but it looks terrible (the renderer is cutting some space at the bottom of every table line of tree) what i did ? As shown in example when JTree component is returned I return my JCheckTree component.
My question is anybody seen working example with combination JCheckBoxTreeTable Component or knows how to write one ?
Any code snipets, examples i would be very greatful.
Mchmielewski
Hi.,
See whether it is useful... It can bring u checkbox in each node and you can select or deselect.
-sps :)
private MyMutableTreeNode topNode = null;
private MyMutableTreeNode mainSection = null;
private MyMutableTreeNode subSection = null;
private MyMutableTreeNode child = null;
private DefaultTreeModel treeModel = null;
// constructor..
public void createTree()
topNode = new MyMutableTreeNode("Root Node");
treeModel = new DefaultTreeModel(topNode);
createNodes(topNode);
jTree1.setModel(treeModel);
MyRenderer renderer = new MyRenderer();
MyCellEditor myEditor = new MyCellEditor();
jTree1.setCellRenderer(renderer); // TO DRAW EACH NODE IN TREE.
jTree1.setCellEditor(myEditor); // TO EDIT OR DO ANY ACTIONS IN THE NODES.
jTree1.setEditable(true); // TO DO ANY ACTION IN THE NODES.
jScrollPane1.setViewportView(jTree1);
public void createNodes(DefaultMutableTreeNode tNode)
mainSection = new MyMutableTreeNode("Parent 1");
tNode.add(mainSection);
subSection = new MyMutableTreeNode("Child 1");
mainSection.add(subSection);
child = new MyMutableTreeNode("Leaf 1");
subSection.add(child);
subSection = new MyMutableTreeNode("Child 2");
mainSection.add(subSection);
child = new MyMutableTreeNode("Leaf 2");
subSection.add(child);
class MyMutableTreeNode extends DefaultMutableTreeNode implements ItemListener
JCheckBox x;
String title;
public MyMutableTreeNode(String title)
super(title);
this.title = title;
x = new JCheckBox(title);
x.addItemListener(this);
x.setBackground(Color.WHITE);
public void itemStateChanged(ItemEvent ie)
MyMutableTreeNode parentNode;
MyMutableTreeNode leaf;
MyMutableTreeNode tempParent;
MyMutableTreeNode tempRoot;
if( ie.getStateChange() == ItemEvent.SELECTED )
int count = getChildCount();
// System.out.println("Selected "+title);
if( count != 0 )
this.getCheckBox().setSelected(true);
for ( int i = 0; i < count; i++)
parentNode = (MyMutableTreeNode)this.getChildAt(i);
if( parentNode.getChildCount() != 0 )
parentNode.getCheckBox().setSelected(true);
for ( int j = 0; j< parentNode.getChildCount(); j++ )
leaf = (MyMutableTreeNode)parentNode.getChildAt(j);
leaf.getCheckBox().setSelected(true);
else
parentNode.getCheckBox().setSelected(true);
else
this.getCheckBox().setSelected(true);
//System.out.println("There are no Child Nodes for "+this.title);
else if( ie.getStateChange() == ItemEvent.DESELECTED )
int count = getChildCount();
if( count != 0 )
this.getCheckBox().setSelected(false);
for ( int i = 0; i < count; i++)
parentNode = (MyMutableTreeNode)this.getChildAt(i);
if( parentNode.getChildCount() != 0 )
parentNode.getCheckBox().setSelected(false);
for ( int j = 0; j < parentNode.getChildCount(); j++ )
leaf = (MyMutableTreeNode)parentNode.getChildAt(j);
leaf.getCheckBox().setSelected(false);
else
parentNode.getCheckBox().setSelected(false);
else
this.getCheckBox().setSelected(false);
jTree1.repaint(); // THIS IS FASTER THAN jTree1.updateUI();
public JCheckBox getCheckBox()
return x;
class MyRenderer implements TreeCellRenderer
public MyRenderer()
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
return ((MyMutableTreeNode)value).getCheckBox();
class MyCellEditor implements TreeCellEditor
public void addCellEditorListener(javax.swing.event.CellEditorListener l)
public void cancelCellEditing()
public Object getCellEditorValue()
return this;
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
return ((MyMutableTreeNode)value).getCheckBox();
public boolean isCellEditable(java.util.EventObject isEditableEvt)
if (isEditableEvt instanceof MouseEvent)
MouseEvent me = (MouseEvent) isEditableEvt;
if (me.getClickCount() == 1)
return true;
return false;
public void removeCellEditorListener(javax.swing.event.CellEditorListener l)
public boolean shouldSelectCell(java.util.EventObject anEvent)
return true;
public boolean stopCellEditing()
return true;
}
Similar Messages
-
SharePoint 2013---How to convert current left Navigation into tree view
Hi All,
I want to convert current left navigation into tree view in SharePoint 2013. When we click on Modify Navigation and set headers and links; I need that should be convert into tree view. All headers should be expandable to thier links.
I just want tree view on navigation headers and links. not for all site and subsites which we can enabled from site settings --> Modify All Site settings --> Tree view
Please help me Master Page editing on Navigation Generation.. Thanks in advance!
Regards,
AnnaHi Anna,
If you want to replace the Quick Launch part with the custom treeview web part in master page, you can comment out or remove the quick launch code block "<!--SPM:<SharePoint:SPNavigationManager id="QuickLaunchNavigationManager.....>....<>-->",
then insert the custom web part snippet code in proper location in seattle master page, then all pages inheriting the seattle master page will have this web part.
Note, please back up the master page before customizing the original master page for recovery.
http://msdn.microsoft.com/en-us/library/office/jj862341(v=office.15).aspx
http://www.sharepointpals.com/post/Add-snippets-in-Page-layout-using-design-manager
Thanks,
Daniel Yang
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]
Daniel Yang
TechNet Community Support -
MDM Hierarchy Table Into Tree (Java WebDynpro)
Hello all,
I have a requirement of showing a MDM Hierarchy Table into Tree UI element.
These are the steps am following:
1) MDM Connectivity
2) Using RetrieveLimitedHierTreeCommand command to retrieve tree structure of the table
3) Using getChildren() method of each node to get the children
4) Made a tree ui element with a recursive node
Now since the Hierarchy table can reach any level of nodes how do i write code for dynamic tree node/leaf generation?
Please guide me through with detailed steps/code if possible?
Regards,
Yogesh BhatiaHi Yogesh,
After getting the HierNode you have to recursively populate the hierarchy tree using the below code:
private void createHierarchyTree( parent_element, com.sap.mdm.data.HierNode HierNode)
if(HierNode != null && HierNode .getChildren() != null)
for(int iChildCount=0 ; iChildCount < HierNode .getChildren().length ; iChildCount++)
IPublic<comp name>.Iparent_element objTreeElement = parent_element.node<Recursive node name>().create<name>Element();
objTreeElement.setattr1(HierNode.getChildren()[iChildCount].getDisplayValue());
objTreeElement.setattr1_Recid(HierNode.getChildren()[iChildCount].getId().id);
parent_element.node<Recursive node name>().addElement(objTreeElement);
// call the method recursively
createHierarchyTree(objTreeElement, HierNode.getChildren()[iChildCount]);
This will populate the tree, you need to create an action in the tree view and link it to TreeNode Type action property using which you can get the selected value.
Hope this helps!!
Cheers,
Arafat -
MDM Hierarchy Table Into Tree UI Control in ABAP WebDynpro & MDM ABAP APIs
Experts,
I am a newbie to ABAP / MDM ABAP APIs. I am looking into the possibility of using Tree as as a UI control in a webdynpro abap application to represent hierarchy tables, perform hierarchy / taxonomy search, create and update records involving hierarchy fields, using MDM ABAP APIs.
I would like to seek inputs to check whether and how, is it possible to use MDM ABAP APIs to:
1. To perform taxonomy search on material table
2. To Create material records in the main table involving taxonomy fields.
3. To search on main table records using taxonomy attribute values as search parameters.
4. To use Tree UI control with in WebDynPro ABAP, to peform above operations.
We intend to use function modules - service calls from within WebDynPro ABAP applications, hence would like to know the feasibility, actual build effort and complexity of function modules.
Inputs and advice on same will be highly appreciated and duly rewarded.
Regards,
Paras1. To perform taxonomy search on material table - if material table is of type Taxonomy then possible
2. To Create material records in the main table involving taxonomy fields - possible . you create records in main table and assign value of field to that of taxonomy table entry
3. To search on main table records using taxonomy attribute values as search parameters. - possiblr
4. To use Tree UI control with in WebDynPro ABAP, to peform above operations. - yes possible
dont mix between hierarchy table and taxonomy table
they are diff in MDM , but it is possible to build UI with WD tree element for each of these types.
all that you said are supported in ABAP APIs
thanks
-Adrivit -
Read directory structure into tree structure
Hi ya,
I want to be able to write a command line program that either takes a root node(directory root) or just takes the directory root from where the program is run reads in the directory tree into a tree structure. Then I want to analyse the tree.
I would like to know what are the best ways to do this and what are the most useful classes.
Thanks a lot for the help,
MartinHere is a quickie du(1) (disk usage) clone that should give some hints. The Getopt class is something I wrote so you won't be able to compile this as such.
import java.io.File;
public class Du
public static void main(String args[])
boolean sum_mode = false;
Getopt getopt = new Getopt(args, "sk");
while (getopt.next()) {
switch (getopt.option()) {
case 's':
sum_mode = true;
break;
case 'k':
break;
default:
System.err.println("du: unknown option \"-" + getopt.optionName() + "\"");
System.exit(1);
if (getopt.parameterCount() == 0) {
du(new File("."), ".", sum_mode, true);
} else {
for (int n = 0; n < getopt.parameterCount(); n++) {
String name = getopt.parameter(n);
du(new File(name), name, sum_mode, true);
private static long du(File file, String path, boolean sum_mode, boolean topmost_file)
long bytes = 0;
if (file.isDirectory()) {
File files[] = file.listFiles();
String sub_path = path + "/" + file.getName();
for (File f : files)
bytes += du(f, sub_path, sum_mode, false);
if (!sum_mode || topmost_file)
System.out.println((bytes / 1024) + "\t" + path + "/" + file.getName());
} else {
bytes = file.length();
if (topmost_file)
System.out.println((bytes / 1024) + "\t" + path + "/" + file.getName());
return bytes;
} -
I have a tree and i have an toolbox (next, previous, last etc).
I want to implement next_record in tree so than the user can go to the next node using the toolbox. What can I do ?
I'm a beginner with Forms :-)
ThanksHi,
find the node you will display highlighted with ftree.find_tree_node.
To toggle highlighting use ftree.set_tree_selection.
eg.
--fill tree with test nodes
--set Node3 highlighted
DECLARE
node ftree.node;
BEGIN
node := ftree.add_tree_node('t.ree', ftree.root_node, ftree.parent_offset, ftree.last_child, ftree.leaf_node, 'Node1', NULL, 'Node1');
node := ftree.add_tree_node('t.ree', ftree.root_node, ftree.parent_offset, ftree.last_child, ftree.leaf_node, 'Node2', NULL, 'Node2');
node := ftree.add_tree_node('t.ree', ftree.root_node, ftree.parent_offset, ftree.last_child, ftree.leaf_node, 'Node3', NULL, 'Node3');
ftree.set_tree_selection('t.ree', node, ftree.select_on);
END;
--toggle higlighting to Node1
--find Node1 by value
--start at root_node
DECLARE
node ftree.node;
BEGIN
node := ftree.find_tree_node('t.ree', 'Node1', ftree.find_next, ftree.node_value, ftree.root_node, ftree.root_node);
if not ftree.id_null(node) then
ftree.set_tree_selection('t.ree', node, ftree.select_on);
end if;
END; -
Puting into JEditorPane HTML file
I want to put into JEditorPane HTML file from my local drive.
How to do that?Hear is example try it.
*(c)pesilEX - 2007
* [email protected]
* Let�s make a open source software world
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.URL;
public class pesilEX extends JFrame implements ActionListener{
JPanel cp;
// Declaring a url to get file name
// Also this can use to get url form online
public URL helpURL;
JScrollPane scrol;
JEditorPane htmlPane;
JButton btn1;
// This string is use to store file name
String fileName;
public pesilEX(){
cp = (JPanel)getContentPane();
cp.setLayout(null);
htmlPane = new JEditorPane();
htmlPane.setEditable(false);
scrol = new JScrollPane();
scrol.getViewport().add(htmlPane);
scrol.setBounds(10,10,370,300);
cp.add(scrol);
btn1 = new JButton("View!");
btn1.setBounds(260,320,120,20);
cp.add(btn1);
btn1.addActionListener(this);
public void actionPerformed(ActionEvent e){
if(e.getSource()==btn1){
// File name you can replace is as you want
fileName = "pesilEX/help.htm";
// Import html file to java
helpURL = getClass().getClassLoader().getResource(fileName);
try{
// Set url to JEditorPane
htmlPane.setPage(helpURL);
catch(Exception er){
System.out.println(er.toString());
public static void main(String[] args){
pesilEX pesil = new pesilEX();
pesil.setSize(400,400);
pesil.setTitle("pesilEX JHtml viewer");
pesil.setResizable(false);
pesil.setVisible(true);
} -
PO going in Unrelease after assigning Advance payment into payment tab
Hello Guys,
I have a issues regarding purchase order's release strategy. when i assing advance payment categoy into Payment Processing tab into header tab of purchase order and save . purchase order goes to unrelease.
it should not be go into unrelease.
kindly guide me regarding this issues.
with regards,
sanjay kumarPO will goes to unreleased, only when the header amount will increase.
Check the same in your case. -
Hi there!
I am using the tree element in web dynpro.
Not the tree in the table.
I need to expand a part of the tree during loading
I do not find an example.
Any help is warmly appreciated.
Thanks in advance, FrankHi,
the "dynamic" tree expansion depends on who you populate the tree content e.g. how you load the data to your tree.
In my application, I have choosen to load the root nodes, first - all over sub-nodes (including items) are loaded "on demand" that means the user clicks on the node. This click will trigger the the action onLoadChildren which pulls the data from a data provider and binds the retrieved data to the corresponding
context node.
This expansion can be perfomed automatically by a recursive method which is called when a user pushes a button called "Expand all"....
I don't have much time to explain the details, but I will provided the source code..., hope it helps!
Darko
Source Code -
Import to the Method:
i_node_ref type IF_WD_CONTEXT_NODE = Reference to the context node
METHOD nav_tree_expand_all.
Data declaration
DATA node_elements TYPE wdr_context_element_set.
DATA node_element LIKE LINE OF node_elements.
DATA child_node TYPE REF TO if_wd_context_node.
DATA ls_tree_attr TYPE zlm_str_tree_gen.
DATA lt_tree TYPE zlm_tty_tree_gen.
Get all node elements
node_elements = i_node_ref->get_elements( ).
Loop over each element
LOOP AT node_elements INTO node_element.
" Get Static attributes
node_element->get_static_attributes( IMPORTING static_attributes = ls_tree_attr ).
" Check if data has already been loaded
IF ls_tree_attr-children_loaded = abap_true.
" now we know that the data has been loaded, only the elements have to be declared as expanded
ls_tree_attr-is_expanded = abap_true.
node_element->set_static_attributes( EXPORTING static_attributes = ls_tree_attr ).
" get possible other nodes recursively
child_node = node_element->get_child_node( 'SUBTREE' ).
me->nav_tree_expand_all( EXPORTING i_node_ref = child_node
i_screen_id = i_screen_id
i_component_id = i_component_id ).
ELSE.
" data has not been loaded yet...
" First load the nodes...
clear lt_tree.
me->get_nav_tree_nodes( .....importing lt_tree.). Custom specific data retrieval
IF lt_tree IS NOT INITIAL.
child_node = node_element->get_child_node( 'SUBTREE' ).
child_node->bind_table( lt_tree ).
" Update Attributes of the node
ls_tree_attr-is_expanded = abap_true.
ls_tree_attr-children_loaded = abap_true.
node_element->set_static_attributes( EXPORTING static_attributes = ls_tree_attr ).
" Call the method again recursively...
me->nav_tree_expand_all( EXPORTING i_node_ref = child_node
i_screen_id = i_screen_id
i_component_id = i_component_id ).
ENDIF.
" ... then load the items
CLEAR lt_tree.
me->get_nav_tree_items( .....importing lt_tree.). Custom specific data retrieval
IF lt_tree IS NOT INITIAL.
" Update Attributes of the node
ls_tree_attr-is_expanded = abap_true.
ls_tree_attr-children_loaded = abap_true.
node_element->set_static_attributes( EXPORTING static_attributes = ls_tree_attr ).
child_node = node_element->get_child_node( 'ITEM' ).
child_node->bind_table( lt_tree ).
ENDIF.
ENDIF.
ENDLOOP.
RETURN.
Edited by: Darko Mocelj on May 7, 2008 8:57 PM -
I'm trying to programmatically select nodes within my JTreeTable, with zero-success...
I imagined the following would be fine for rendering the selection.
JTree tree = treeTable.getTree();
tree.setExpandsSelectedPaths(true);
treePath = treePath.pathByAddingChild(someObject);
tree.setSelectionPath(treePath);
The parent node is properly expanded and the new child becomes visible, however, there is no selection.
Any help very welcome.
thanks,
ianHi monicaba!
I've had the same problem. The Method setSelectionPath() did not do what it should. I read your articles and tried out your suggestion to comment the delayedFireTableDataChanged() line. But it did not solve the problem.
Anyway, I found another way to make it work and I want to share it with you ;-) :
After inserting the new node and after updating the display via calling fireTreeNodesInserted(), I return the new tree path to the new child (addChildToParent() is my own method of the tree table model):
// Insert child into tree table, update the display via
// fireTreeNodesInserted() and return the new inserted tree path
_selectionPath = treeTableModel.addChildToParent(...);
Then I call the invokeLater() method of SwingUtilities to select the new path (Jtretbl_Data is my JTreeTable!):
// Make the new path selected
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Jtretbl_Data.getTree().setSelectionPath(_selectionPath);
The disadvantage of this is that the variable _selectionPath has to be a member variable of my applet. Perhaps I could improve that point.
Best regards,
Peter -
Tutorial do ALV Tree programming
Hai all,
I really want to create ABAP program using ALV tree, but i dunno how to use the ALV tree. Is someone have the tutorial have to do that one. or maybe sample code how to do ALV tree. Thnks in advance.<b>ALV TREE DEMO PROGRAM .
HOPE THIS WILL HELP YOU IN UNDERSTANDING ALV TREE.</b>
CLASS cl_gui_column_tree DEFINITION LOAD.
CLASS cl_gui_cfw DEFINITION LOAD.
DATA: go_grid TYPE REF TO cl_gui_alv_grid.
DATA: ro_grid TYPE REF TO cl_gui_alv_grid.
DATA tree1 TYPE REF TO cl_gui_alv_tree.
DATA mr_toolbar TYPE REF TO cl_gui_toolbar.
DATA : gt_checked TYPE lvc_t_chit,
gs_checked LIKE LINE OF gt_checked,
l_part_key TYPE lvc_nkey,
gt_node TYPE lvc_s_chit-nodekey.
INCLUDE <icon>.
INCLUDE zamit_alv_tree_toolbar_event.
INCLUDE zbcalv_tree_event_receiver.
*DATA: toolbar_event_receiver TYPE REF TO lcl_toolbar_event_receiver.
DATA: gt_sflight TYPE sflight OCCURS 0, "Output-Table
gt_fieldcatalog TYPE lvc_t_fcat, "Fieldcatalog
ok_code LIKE sy-ucomm. "OK-Code
START-OF-SELECTION.
END-OF-SELECTION.
CALL SCREEN 100.
*& Module PBO OUTPUT
process before output
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
IF tree1 IS INITIAL.
PERFORM init_tree.
else.
CALL METHOD me->refresh_table_display
EXCEPTIONS
PROGRAM_ERROR = 1
others = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
ENDMODULE. " PBO OUTPUT
*& Module PAI INPUT
process after input
MODULE pai INPUT.
CASE ok_code.
WHEN 'EXIT' OR 'BACK' OR 'CANC'.
PERFORM exit_program.
*mrk
WHEN 'MOVE'.
PERFORM check_selection.
WHEN 'MBAK'.
PERFORM another_selection.
WHEN 'ALL'.
PERFORM select_all.
WHEN 'CLEAR'.
PERFORM clear_all.
WHEN 'DELETE'.
PERFORM delete_all.
WHEN 'EXPAND'.
PERFORM expand_all.
WHEN 'COLLAPSE'.
PERFORM collapse_all.
WHEN OTHERS.
CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
CLEAR ok_code.
CALL METHOD cl_gui_cfw=>flush.
ENDMODULE. " PAI INPUT
*& Form build_fieldcatalog
build fieldcatalog for structure sflight
FORM build_fieldcatalog.
get fieldcatalog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
ct_fieldcat = gt_fieldcatalog.
change fieldcatalog
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
LOOP AT gt_fieldcatalog INTO ls_fieldcatalog.
CASE ls_fieldcatalog-fieldname.
WHEN 'CARRID' OR 'CONNID' OR 'FLDATE'.
ls_fieldcatalog-no_out = 'X'.
ls_fieldcatalog-key = ''.
WHEN 'PRICE' OR 'SEATSOCC' OR 'SEATSMAX' OR 'PAYMENTSUM'.
ls_fieldcatalog-do_sum = 'X'.
ENDCASE.
MODIFY gt_fieldcatalog FROM ls_fieldcatalog.
ENDLOOP.
ENDFORM. " build_fieldcatalog
*& Form build_hierarchy_header
build hierarchy-header-information
-->P_L_HIERARCHY_HEADER strucxture for hierarchy-header
FORM build_hierarchy_header CHANGING
p_hierarchy_header TYPE treev_hhdr.
p_hierarchy_header-heading = 'Hierarchy Header'. "#EC NOTEXT
p_hierarchy_header-tooltip =
'This is the Hierarchy Header !'. "#EC NOTEXT
p_hierarchy_header-width = 30.
p_hierarchy_header-width_pix = ''.
ENDFORM. " build_hierarchy_header
*& Form exit_program
free object and leave program
FORM exit_program.
CALL METHOD tree1->free.
LEAVE PROGRAM.
ENDFORM. " exit_program
*& Form check_selection
text
--> p1 text
<-- p2 text
FORM check_selection .
create container for alv-tree
DATA: l_tree_container_name(30) TYPE c,
l_custom_container2 TYPE REF TO cl_gui_custom_container.
l_tree_container_name = 'TREE2'.
IF sy-batch IS INITIAL.
CREATE OBJECT l_custom_container2
EXPORTING
container_name = l_tree_container_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
ENDIF.
CREATE OBJECT go_grid
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = l_custom_container2
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
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.
PERFORM load_data_into_grid.
*data: lt_nodes type LVC_T_NKEY,
ls_nodes like line of lt_nodes,
ls_checked like line of gt_checked.
*loop at gt_checked into ls_checked.
ls_nodes = ls_checked-nodekey.
append ls_nodes to lt_nodes.
*endloop.
*CALL METHOD tree1->unselect_nodes
EXPORTING
it_node_key = lt_nodes
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
DP_ERROR = 2
MULTIPLE_NODE_SELECTION_ONLY = 3
ERROR_IN_NODE_KEY_TABLE = 4
FAILED = 5
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.
ENDFORM. " check_selection
*& Form another_selection
text
--> p1 text
<-- p2 text
FORM another_selection .
create container for alv-tree
DATA: l_tree_container_name(30) TYPE c,
l_custom_container2 TYPE REF TO cl_gui_custom_container.
l_tree_container_name = 'TREE2'.
IF sy-batch IS INITIAL.
CREATE OBJECT l_custom_container2
EXPORTING
container_name = l_tree_container_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
ENDIF.
CREATE OBJECT ro_grid
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = l_custom_container2
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
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.
PERFORM load_data_into_grid1.
DATA: lt_unsel TYPE lvc_t_nkey,
ls_unsel LIKE LINE OF lt_unsel.
LOOP AT gt_checked INTO gs_checked.
ls_unsel = gs_checked-nodekey.
APPEND ls_unsel TO lt_unsel.
ENDLOOP.
CALL METHOD tree1->unselect_nodes
EXPORTING
it_node_key = lt_unsel
EXCEPTIONS
cntl_system_error = 1
dp_error = 2
multiple_node_selection_only = 3
error_in_node_key_table = 4
failed = 5
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.
*CALL METHOD tree1->unselect_all
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
FAILED = 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.
DATA: text TYPE lvc_value,
item TYPE lvc_t_layi,
node TYPE lvc_s_layn,
inode TYPE lvc_nkey.
FIELD-SYMBOLS: <wa> TYPE ANY.
DATA: l_dref_wa LIKE LINE OF gt_sflight.
ASSIGN l_dref_wa TO <wa>.
READ TABLE gt_checked INTO gs_checked WITH KEY nodekey = 3.
inode = gs_checked-nodekey.
CALL METHOD tree1->get_outtab_line
EXPORTING
i_node_key = inode
IMPORTING
e_outtab_line = <wa>
e_node_text = text
et_item_layout = item
es_node_layout = node
EXCEPTIONS
node_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DATA: lt_layout TYPE lvc_t_laci,
layout LIKE LINE OF lt_layout.
layout-chosen = 'X'.
layout-fieldname = tree1->c_hierarchy_column_name.
ls_item_layout-chosen = 'X'. "To give default checkbox value checked
layout-class = cl_gui_column_tree=>item_class_checkbox.
layout-editable = 'X'.
LAYOUT-U_CHOSEN = 'X'.
APPEND layout TO lt_layout.
CALL METHOD tree1->change_node
EXPORTING
i_node_key = inode
i_outtab_line = <wa>
IS_NODE_LAYOUT =
it_item_layout = lt_layout
I_NODE_TEXT =
I_U_NODE_TEXT =
EXCEPTIONS
node_not_found = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*CALL METHOD tree1->change_item
EXPORTING
i_node_key = inode
i_fieldname = gs_checked-FIELDNAME
i_data = <wa>
I_U_DATA = ''
IS_ITEM_LAYOUT = layout
EXCEPTIONS
NODE_NOT_FOUND = 1
others = 2
*IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
*loop at lt_unsel into ls_unsel.
*CALL METHOD tree1->update_checked_items
EXPORTING
i_node_key = ls_unsel
i_fieldname = ''
i_checked = ''
EXCEPTIONS
PROGRAM_ERROR = 1
others = 2
*IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
*endif.
ENDFORM. " another_selection
*& Form select_all
text
--> p1 text
<-- p2 text
FORM select_all .
CONSTANTS: c_x(1) TYPE c VALUE 'X'.
*********Check box modifications.
CALL METHOD tree1->delete_all_nodes
EXCEPTIONS
failed = 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.
clear l_part_key.
create hierarchy
PERFORM create_hierarchy USING c_x.
CALL METHOD tree1->expand_node
EXPORTING
i_node_key = gt_node
I_LEVEL_COUNT = 1
i_expand_subtree = 'X'
EXCEPTIONS
failed = 1
illegal_level_count = 2
cntl_system_error = 3
node_not_found = 4
cannot_expand_leaf = 5
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.
add own functioncodes to the toolbar
perform change_toolbar.
register events
perform register_events.
adjust column_width
call method tree1->COLUMN_OPTIMIZE.
ENDFORM. " select_all
*& Form clear_all
text
--> p1 text
<-- p2 text
FORM clear_all .
CONSTANTS: c_x(1) TYPE c VALUE space.
*********Check box modifications.
CALL METHOD tree1->delete_all_nodes
EXCEPTIONS
failed = 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.
create hierarchy
PERFORM create_hierarchy USING c_x.
CALL METHOD tree1->expand_node
EXPORTING
i_node_key = gt_node
I_LEVEL_COUNT = 1
i_expand_subtree = 'X'
EXCEPTIONS
failed = 1
illegal_level_count = 2
cntl_system_error = 3
node_not_found = 4
cannot_expand_leaf = 5
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.
ENDFORM. " clear_all
*& Form delete_all
text
--> p1 text
<-- p2 text
FORM delete_all .
*********Check box modifications.
CALL METHOD tree1->delete_all_nodes
EXCEPTIONS
failed = 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.
ENDFORM. " delete_all
*& Form expand_all
text
--> p1 text
<-- p2 text
FORM expand_all .
CALL METHOD tree1->expand_node
EXPORTING
i_node_key = gt_node
I_LEVEL_COUNT = 1
i_expand_subtree = 'X'
EXCEPTIONS
failed = 1
illegal_level_count = 2
cntl_system_error = 3
node_not_found = 4
cannot_expand_leaf = 5
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.
ENDFORM. " expand_all
*& Form collapse_all
text
--> p1 text
<-- p2 text
FORM collapse_all .
CALL METHOD tree1->collapse_all_nodes
EXCEPTIONS
failed = 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.
ENDFORM. " collapse_all
*& Form load_data_into_grid
text
--> p1 text
<-- p2 text
FORM load_data_into_grid .
DATA:
For parameter IS_VARIANT
l_layout TYPE disvariant,
gs_layout TYPE lvc_s_layo.
DATA gi_sflight TYPE TABLE OF zsflight.
Load data into the grid and display them
l_layout-report = sy-repid.
gs_layout-grid_title = 'Amits Test Program'.
gs_layout-sel_mode = 'A'.
SELECT *
FROM zsflight
INTO TABLE gi_sflight.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
is_layout = gs_layout
is_variant = l_layout
i_save = 'A'
CHANGING
it_outtab = gi_sflight.
ENDFORM. " load_data_into_grid
*& Form load_data_into_grid
text
--> p1 text
<-- p2 text
FORM load_data_into_grid1.
DATA:
For parameter IS_VARIANT
l_layout TYPE disvariant,
gs_layout TYPE lvc_s_layo.
DATA gi_sflight TYPE TABLE OF zapempl.
Load data into the grid and display them
l_layout-report = sy-repid.
gs_layout-grid_title = 'Rams Test Program'.
gs_layout-sel_mode = 'A'.
SELECT *
FROM zapempl
INTO TABLE gi_sflight.
CALL METHOD ro_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'ZAPEMPL'
is_layout = gs_layout
is_variant = l_layout
i_save = 'A'
CHANGING
it_outtab = gi_sflight.
ENDFORM. " load_data_into_grid1
*& Form build_header
build table for html_header
--> p1 text
<-- p2 text
FORM build_comment USING
pt_list_commentary TYPE slis_t_listheader
p_logo TYPE sdydo_value.
DATA: ls_line TYPE slis_listheader.
LIST HEADING LINE: TYPE H
CLEAR ls_line.
ls_line-typ = 'H'.
LS_LINE-KEY: NOT USED FOR THIS TYPE
ls_line-info = 'ALV-tree-demo: flight-overview'. "#EC NOTEXT
APPEND ls_line TO pt_list_commentary.
STATUS LINE: TYPE S
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = 'valid until'. "#EC NOTEXT
ls_line-info = 'January 29 1999'. "#EC NOTEXT
APPEND ls_line TO pt_list_commentary.
ls_line-key = 'time'.
ls_line-info = '2.00 pm'. "#EC NOTEXT
APPEND ls_line TO pt_list_commentary.
ACTION LINE: TYPE A
CLEAR ls_line.
ls_line-typ = 'A'.
LS_LINE-KEY: NOT USED FOR THIS TYPE
ls_line-info = 'actual data'. "#EC NOTEXT
APPEND ls_line TO pt_list_commentary.
p_logo = 'ENJOYSAP_LOGO'.
ENDFORM. "build_comment
*& Form create_hierarchy
text
--> p1 text
<-- p2 text
FORM create_hierarchy USING p_x.
DATA: ls_sflight TYPE sflight,
lt_sflight TYPE sflight OCCURS 0.
get data
SELECT * FROM sflight INTO TABLE lt_sflight
UP TO 200 ROWS .
SORT lt_sflight BY carrid connid fldate.
add data to tree
DATA: l_carrid_key TYPE lvc_nkey,
l_connid_key TYPE lvc_nkey,
l_last_key TYPE lvc_nkey.
l_part_key TYPE lvc_nkey
PERFORM add_carrid_line USING ls_sflight
CHANGING l_part_key.
gt_node = l_part_key.
LOOP AT lt_sflight INTO ls_sflight.
ON CHANGE OF ls_sflight-carrid.
PERFORM add_carrid_line USING ls_sflight
l_part_key
CHANGING l_carrid_key.
PERFORM add_connid_line USING ls_sflight
l_carrid_key
CHANGING l_connid_key.
PERFORM add_complete_line USING ls_sflight
l_connid_key
p_x
CHANGING l_last_key.
CONTINUE.
ENDON.
ON CHANGE OF ls_sflight-connid.
PERFORM add_connid_line USING ls_sflight
l_carrid_key
CHANGING l_connid_key.
PERFORM add_complete_line USING ls_sflight
l_connid_key
p_x
CHANGING l_last_key.
CONTINUE.
ENDON.
PERFORM add_complete_line USING ls_sflight
l_connid_key
p_x
CHANGING l_last_key.
ENDLOOP.
calculate totals
CALL METHOD tree1->update_calculations.
this method must be called to send the data to the frontend
CALL METHOD tree1->frontend_update.
ENDFORM. " create_hierarchy
*& Form add_carrid_line
add hierarchy-level 1 to tree
-->P_LS_SFLIGHT sflight
-->P_RELEATKEY relatkey
<-->p_node_key new node-key
FORM add_carrid_line USING ps_sflight TYPE sflight
p_relat_key TYPE lvc_nkey
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value,
ls_sflight TYPE sflight.
set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
ls_item_layout TYPE lvc_s_layi.
ls_item_layout-t_image = '@3P@'.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
ls_item_layout-style =
cl_gui_column_tree=>style_intensifd_critical.
APPEND ls_item_layout TO lt_item_layout.
add node
l_node_text = ps_sflight-carrid.
CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_sflight
it_item_layout = lt_item_layout
IMPORTING
e_new_node_key = p_node_key.
ENDFORM. " add_carrid_line
*& Form add_connid_line
add hierarchy-level 2 to tree
-->P_LS_SFLIGHT sflight
-->P_RELEATKEY relatkey
<-->p_node_key new node-key
FORM add_connid_line USING ps_sflight TYPE sflight
p_relat_key TYPE lvc_nkey
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value,
ls_sflight TYPE sflight.
set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
ls_item_layout TYPE lvc_s_layi.
ls_item_layout-t_image = '@3Y@'.
ls_item_layout-style =
cl_gui_column_tree=>style_intensified.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
APPEND ls_item_layout TO lt_item_layout.
add node
l_node_text = ps_sflight-connid.
CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_sflight
it_item_layout = lt_item_layout
IMPORTING
e_new_node_key = p_node_key.
ENDFORM. " add_connid_line
*& Form add_cmplete_line
add hierarchy-level 3 to tree
-->P_LS_SFLIGHT sflight
-->P_RELEATKEY relatkey
<-->p_node_key new node-key
FORM add_complete_line USING ps_sflight TYPE sflight
p_relat_key TYPE lvc_nkey
p_x
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value.
set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
ls_item_layout TYPE lvc_s_layi.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
ls_item_layout-chosen = p_x. "To give default checkbox value checked
ls_item_layout-class = cl_gui_column_tree=>item_class_checkbox.
ls_item_layout-editable = 'X'.
APPEND ls_item_layout TO lt_item_layout.
l_node_text = ps_sflight-fldate.
CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = ps_sflight
i_node_text = l_node_text
it_item_layout = lt_item_layout
IMPORTING
e_new_node_key = p_node_key.
ENDFORM. " add_complete_line
*& Form register_events
text
--> p1 text
<-- p2 text
FORM register_events.
define the events which will be passed to the backend
DATA: lt_events TYPE cntl_simple_events,
l_event TYPE cntl_simple_event.
define the events which will be passed to the backend
l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_click.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
APPEND l_event TO lt_events.
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 <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
set Handler
DATA: l_event_receiver TYPE REF TO lcl_tree_event_receiver.
CREATE OBJECT l_event_receiver.
SET HANDLER l_event_receiver->handle_node_ctmenu_request
FOR tree1.
SET HANDLER l_event_receiver->handle_node_ctmenu_selected
FOR tree1.
SET HANDLER l_event_receiver->handle_item_ctmenu_request
FOR tree1.
SET HANDLER l_event_receiver->handle_item_ctmenu_selected
FOR tree1.
SET HANDLER l_event_receiver->handle_checkbox_change FOR tree1.
ENDFORM. " register_events
*& Form change_toolbar
text
--> p1 text
<-- p2 text
FORM change_toolbar.
DATA: toolbar_event_receiver TYPE REF TO lcl_toolbar_event_receiver.
get toolbar control
CALL METHOD tree1->get_toolbar_object
IMPORTING
er_toolbar = mr_toolbar.
CHECK NOT mr_toolbar IS INITIAL.
add seperator to toolbar
CALL METHOD mr_toolbar->add_button
EXPORTING
fcode = ''
icon = ''
butn_type = cntb_btype_sep
text = ''
quickinfo = 'This is a Seperator'. "#EC NOTEXT
add Standard Button to toolbar (for Delete Subtree)
CALL METHOD mr_toolbar->add_button
EXPORTING
fcode = 'DELETE'
icon = '@18@'
butn_type = cntb_btype_button
text = ''
quickinfo = 'Delete subtree'. "#EC NOTEXT
add Dropdown Button to toolbar (for Insert Line)
CALL METHOD mr_toolbar->add_button
EXPORTING
fcode = 'INSERT_LC'
icon = '@17@'
butn_type = cntb_btype_dropdown
text = ''
quickinfo = 'Insert Line'. "#EC NOTEXT
set event-handler for toolbar-control
CREATE OBJECT toolbar_event_receiver.
SET HANDLER toolbar_event_receiver->on_function_selected
FOR mr_toolbar.
SET HANDLER toolbar_event_receiver->on_toolbar_dropdown
FOR mr_toolbar.
ENDFORM. " change_toolbar
*& Form init_tree
text
--> p1 text
<-- p2 text
FORM init_tree.
create fieldcatalog for structure sflight
PERFORM build_fieldcatalog.
create container for alv-tree
DATA: l_tree_container_name(30) TYPE c,
l_custom_container TYPE REF TO cl_gui_custom_container.
l_tree_container_name = 'TREE1'.
IF sy-batch IS INITIAL.
CREATE OBJECT l_custom_container
EXPORTING
container_name = l_tree_container_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
ENDIF.
create tree control
CREATE OBJECT tree1
EXPORTING
parent = l_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple "node_sel_mode_single
item_selection = 'X'
no_html_header = ''
no_toolbar = ''
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 <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
create Hierarchy-header
DATA l_hierarchy_header TYPE treev_hhdr.
PERFORM build_hierarchy_header CHANGING l_hierarchy_header.
create info-table for html-header
DATA: lt_list_commentary TYPE slis_t_listheader,
l_logo TYPE sdydo_value.
PERFORM build_comment USING
lt_list_commentary
l_logo.
repid for saving variants
DATA: ls_variant TYPE disvariant.
ls_variant-report = sy-repid.
create emty tree-control
CALL METHOD tree1->set_table_for_first_display
EXPORTING
is_hierarchy_header = l_hierarchy_header
it_list_commentary = lt_list_commentary
i_logo = l_logo
i_background_id = 'ALV_BACKGROUND'
i_save = 'A'
is_variant = ls_variant
CHANGING
it_outtab = gt_sflight "table must be emty !!
it_fieldcatalog = gt_fieldcatalog.
CONSTANTS: c_s(1) TYPE c VALUE space.
create hierarchy
PERFORM create_hierarchy USING c_s.
add own functioncodes to the toolbar
PERFORM change_toolbar.
register events
PERFORM register_events.
adjust column_width
call method tree1->COLUMN_OPTIMIZE.
ENDFORM. " init_tree -
Unable to expand child links in ALV Tree
Hi,
I have written the following code for ALV Tree using function modules.
REPORT ZSID_ALV_TREE.
type pool declarations for tree
TYPE-POOLS : fibs,stree.
tables: ekko.
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
it_ekpo TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
it_emptytab TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko,
wa_ekpo TYPE t_ekko.
DATA:w_repid type sy-cprog.
*Data declaration for additional node information
DATA : t_node TYPE snodetext.
*Internal table and wa decl for nodes
DATA : it_node LIKE TABLE OF t_node INITIAL SIZE 0,
wa_node LIKE t_node.
*Start of selection event
START-OF-SELECTION.
*Select the data for tree
PERFORM fetch_data.
*Build the hierarchy for tree
PERFORM build_hierarchy.
*Build Tree for display
PERFORM build_tree.
*& Form fetch_data
text
--> p1 text
<-- p2 text
FORM fetch_data .
SELECT ebeln
up to 10 rows
FROM ekko
INTO corresponding fields of TABLE it_ekko .
loop at it_ekko into wa_ekko.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
FROM ekpo
appending TABLE it_ekpo
where ebeln eq wa_ekko-ebeln.
endloop.
endform.
*& Form build_hierarchy
text
--> p1 text
<-- p2 text
FORM build_hierarchy .
*Building the nodes and hierarchy for tree
CLEAR : it_node[], wa_node.
wa_node-type = 'T'.
wa_node-name = 'Product Hierarchy Level'.
wa_node-tlevel = '01'.
wa_node-nlength = '35'.
wa_node-color = '4'.
wa_node-text = 'Test'.
wa_node-tlength ='20'.
wa_node-tcolor = 3.
APPEND wa_node TO it_node.
CLEAR wa_node.
loop at it_ekpo into wa_ekpo.
wa_node-type = 'P'.
wa_node-name = 'Purchasing Doc'.
wa_node-tlevel = '02'.
wa_node-nlength = '25'.
wa_node-color = '4'.
wa_node-text = wa_ekpo-ebeln.
wa_node-tlength ='20'.
wa_node-tcolor = 3.
APPEND wa_node TO it_node.
CLEAR wa_node.
*Filling the values of internal table into tree
wa_node-type = 'P'.
wa_node-name = 'Material No'.
wa_node-tlevel = '03'.
wa_node-nlength = '20'.
wa_node-color = '1'.
wa_node-text = wa_ekpo-matnr.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
ENDLOOP.
ENDFORM. " build_hierarchy
*& Form build_tree
text
--> p1 text
<-- p2 text
FORM build_tree .
*Fm for constructing the tree
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = it_node.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
w_repid = SY-CPROG.
*FM for displaying the tree
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
CALLBACK_PROGRAM = w_repid
CALLBACK_USER_COMMAND = 'USER1_COMMAND'
CALLBACK_TEXT_DISPLAY =
CALLBACK_MOREINFO_DISPLAY =
CALLBACK_COLOR_DISPLAY =
CALLBACK_TOP_OF_PAGE =
CALLBACK_GUI_STATUS =
CALLBACK_CONTEXT_MENU =
STATUS = 'IMPLICIT'
CHECK_DUPLICATE_NAME = '0'
COLOR_OF_NODE = '4'
COLOR_OF_MARK = '3'
COLOR_OF_LINK = '1'
COLOR_OF_MATCH = '5'
LOWER_CASE_SENSITIVE = 'X'
MODIFICATION_LOG = 'X'
NODE_LENGTH = 40
TEXT_LENGTH = 75
TEXT_LENGTH1 = 0
TEXT_LENGTH2 = 0
RETURN_MARKED_SUBTREE = 'X'
SCREEN_START_COLUMN = 0
SCREEN_START_LINE = 0
SCREEN_END_COLUMN = 0
SCREEN_END_LINE = 0
SUPPRESS_NODE_OUTPUT = 'X'
LAYOUT_MODE = ' '
USE_CONTROL = 'L'.
IMPORTING
F15 =
ENDFORM. " build_tree
FORM USER1_COMMAND TABLES node STRUCTURE seucomm
USING command
CHANGING value(exit)
VALUE(LIST_REFRESH).
write 'Hi'.
endform.
But I have a problem
1. I can expand the child links in tree structure when I comment the exporting parameter CALLBACK_USER_COMMAND in the function Module 'RS_TREE_LIST_DISPLAY'.
2 But when i uncomment the exporting parameter I am unable to expand the child links in output.
Please let me know if i have missed something in the code.
Useful answers will be rewarded
Regards,
SiddharthHi Sidhhart,
Check out this prog.
REPORT Z_KULDEEP_ALV_HIERARCHY
message-id zord
line-size 270.
Tables:
Vbap,
Vbak.
*& PROGRAM VARIABLES
type-pools slis.
*& INTERNAL TABLES & STRUCTURES
data:
begin of t_header occurs 0,
EXPCOL type c,
vbeln type vbak-vbeln,
audat type vbak-audat,
vkorg type vbak-vkorg,
vtweg type vbak-vtweg,
spart type vbak-spart,
end of t_header,
begin of t_item occurs 0,
vbeln type vbap-vbeln,
posnr type vbap-posnr,
matnr type vbap-matnr,
arktx type vbap-arktx,
pstyv type vbap-pstyv,
end of t_item,
t_fieldcat type standard table of slis_fieldcat_alv with header line,
t_event type standard table of slis_alv_event with header line,
x_keyinfo type slis_keyinfo_alv,
x_layout type slis_layout_alv,
x_variant like disvariant.
*& GLOBAL VARIABLES
data:
g_repid type sy-repid,
g_formname type slis_formname value 'TOP_OF_PAGE'.
*& SELECTION SCREEN *
selection-screen begin of block a with frame title text-000.
Select-options : s_date for vbak-audat obligatory.
p_date type vbak-audat.
selection-screen end of block a.
*& INITIALIZATION *
initialization.
clear : g_repid,t_header,t_item.
refresh : t_header,t_item.
g_repid = sy-repid.
*& AT SELECTION-SCREEN *
at selection-screen.
if s_date-high > sy-datum.
message e001.
endif.
start-of-selection.
select vbeln audat vkorg vtweg spart from vbak
into corresponding fields of table t_header
where audat in s_date.
select vbeln posnr matnr arktx pstyv from vbap
into table t_item
for all entries in t_header
where vbeln = t_header-vbeln.
end-of-selection.
perform sub_display_alv.
*& Form sub_display_alv
text
--> p1 text
<-- p2 text
form sub_display_alv.
*column 1
perform sub_populate_fieldcatalog using:
'VBELN' " field name
'T_HEADER' " table name
'ORDER' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 2
perform sub_populate_fieldcatalog using:
'AUDAT' " field name
'T_HEADER' " table name
'ORDERDATE' " column heading
'10' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 3
perform sub_populate_fieldcatalog using:
'VKORG' " field name
'T_HEADER' " table name
'SALES ORG' " column heading
'6' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 4
perform sub_populate_fieldcatalog using:
'VTWEG' " field name
'T_HEADER' " table name
'DIVISION' " column heading
'2' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 5
perform sub_populate_fieldcatalog using:
'SPART' " field name
'T_HEADER' " table name
'CHANNEL' " column heading
'4' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 6
perform sub_populate_fieldcatalog using:
'vbeln' " field name
'T_item' " table name
'Order' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 7
perform sub_populate_fieldcatalog using:
'POSNR' " field name
'T_ITEM' " table name
'SALES DOC.ITEM' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 8
perform sub_populate_fieldcatalog using:
'MATNR' " field name
'T_ITEM' " table name
'MATERIAL' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 9
perform sub_populate_fieldcatalog using:
'ARKTX' " field name
'T_ITEM' " table name
'SALES ORDER ITEM' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 10
perform sub_populate_fieldcatalog using:
'PSTYV' " field name
'T_ITEM' " table name
'ITEM CATEGORY' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
perform sub_assign_events.
Create a Layout for the ALV
perform sub_layout.
Define the key fields that links the header & item tables
perform sub_define_key.
dispaly list
perform sub_call_list_display.
endform. " sub_display_alv
*& Form sub_populate_fieldcatalog
text
-->P_G_FIELDCAT text
-->P_0198 text
-->P_0199 text
-->P_0200 text
-->P_0201 text
-->P_0202 text
-->P_0203 text
-->P_0204 text
-->P_0205 text
-->P_0206 text
-->P_0207 text
-->P_0208 text
-->P_0209 text
-->P_0210 text
-->P_0211 text
-->P_0212 text
-->P_0213 text
form sub_populate_fieldcatalog using
l_fieldname
l_tabname
l_column_heading
l_outputlen
l_fix_column
l_key
l_no_out
l_do_sum
l_no_sum
l_input
l_cfieldname
l_datatype
l_hotspot.
t_fieldcat-fieldname = l_fieldname.
t_fieldcat-tabname = l_tabname.
t_fieldcat-reptext_ddic = l_column_heading.
t_fieldcat-outputlen = l_outputlen.
t_fieldcat-fix_column = l_fix_column.
t_fieldcat-key = l_key.
t_fieldcat-no_out = l_no_out.
t_fieldcat-do_sum = l_do_sum.
t_fieldcat-no_sum = l_no_sum.
t_fieldcat-cfieldname = l_cfieldname.
t_fieldcat-datatype = l_datatype.
t_fieldcat-hotspot = l_hotspot.
append t_fieldcat.clear t_fieldcat.
endform. " sub_populate_fieldcatalog
*& Form sub_assign_events
text
--> p1 text
<-- p2 text
form sub_assign_events.
refresh t_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 1
importing
et_events = t_event[]
exceptions
list_type_wrong = 1
others = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Read the record for the top-of-page event
read table t_event with key slis_ev_top_of_page.
if sy-subrc = 0.
t_event-form = g_formname.
append t_event.
endif.
endform. " sub_assign_events
*& Form SUB_LAYOUT
text
--> p1 text
<-- p2 text
form sub_layout.
clear x_layout.
x_layout-f2code = 'QUOTE'.
x_layout-zebra = 'X'.
x_layout-expand_fieldname = 'EXPCOL'. " Field for expand/collapse
*Stat
x_layout-colwidth_optimize = 'X'.
x_layout-no_totalline = 'X'. " 0001+
endform. " SUB_LAYOUT
*& Form SUB_DEFINE_KEY
text
--> p1 text
<-- p2 text
form sub_define_key.
clear x_keyinfo.
x_keyinfo-header01 = 'VBELN'.
x_keyinfo-item01 = 'VBELN'.
endform. " SUB_DEFINE_KEY
form top_of_page.
write :/10 sy-datum, 20 sy-pagno, 30 sy-uname.
endform.
form sub_user_command using f_ucomm like sy-ucomm
f_selfield type slis_selfield.
if f_ucomm = 'QUOTE'.
if f_selfield-fieldname = 'VBELN'.
Set Parameter id 'AUN' field f_selfield-value.
call transaction 'VA03'.
endif.
endif.
endform.
*& Form sub_call_list_display
text
--> p1 text
<-- p2 text
form sub_call_list_display.
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_user_command = 'SUB_USER_COMMAND '
is_layout = x_layout
it_fieldcat = t_fieldcat[]
i_save = 'A'
it_events = t_event[]
i_tabname_header = 'T_HEADER'
i_tabname_item = 'T_ITEM'
is_keyinfo = x_keyinfo
tables
t_outtab_header = t_header[]
t_outtab_item = t_item[]
exceptions
program_error = 1
others = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " sub_call_list_display -
Please Help! After downloading an album and dragging it into itunes I end up having multiple copies of the album on my hard drive. I do have (under Itunes preferences, advanced) copy songs into itunes library "checked". I'm sure this is the reason for the multiple copies. When I try to delete one of the copies of the album and go back to itunes and try playing a song, I get a red exclamtion point next to the song with an error message saying itunes cannot locate file. My questions are, Does Itunes literally make a copy of the song? If so , How do you know which file to delete?
Sony's own entertainment software on the Vaio plays merry **** with iTunes, worse there's no telling when it will kick in.
First head over to the Sony Vaio site and get the update for the software, that will stop it from messing with the iTunes database/library files when you connect your iPod.
http://support.apple.com/kb/TS2715
http://esupport.sony.com/US/perl/swu-download.pl?mdl=VGNP588EQ&updid=4526&osid=28
With that stopped you can add the music back without fear of this happening again. -
How do I prevent the patch from advancing multiple times per switch press?
I'm using Mainstage 2.1.3 with a Roland RD-300SX. I have an FS-5U foot switch that I'd like to use to advance patches plugged into the Roland's control switch port. Regardless of what I've set the Roland to send for that port, it sends one or two messages with a value less than 127 before sending the value of 127. This causes Mainstage to advance 2 or 3 patches each time I press the switch.
I saw that recent release notes said that this didn't happen for the sustain pedal now. Indeed, it does not. However, I need the sustain pedal to sustain.
Is there any way to get Mainstage to only advance one patch in this situation? Perhaps set a threshold value for the action?I've had this problem - bad polarity on the pedal was my demon.
I have found a very stable configuratio.
On my 88 note midi-master keyboard, the lowest note has been assigned to step back one patch, and the next black note, to advance one patch.
This works just fine, and these are notes I never use - just be careful if you do big "sweeps" of the keyboard to STOP before these last two notes.
Sort of "off" subject.
Mainsatge 2.2.1 and OS 10.7.4 are unstable.
Deleting the "CPU/Ram" meter has been suggested as a fix, or shell out for MS 2.2.2
Or, apparently OS 10.8 fixes the stability problem.
Good luck -
After advance payment made against PO system is allowing for ammendment
Issue is there is a PO for some amount 5000 as per purchase request we have made an advance payment Later on we have learned that they have decided to cancel the freight cost as indicated in our PO and subsequently amended the PO value to INR 4500.
Could you please check why the system allowing the amendment to happen even though there was an existing advance payment posted into the system
<<<<<<Text Removed>>>>>>>
Note : Follow forum rules.
Edited by: sapmm99 on Nov 21, 2011 5:48 PM
Edited by: Jeyakanthan A on Nov 21, 2011 11:48 PMI dont know of any setting to restrcit this.
But how would you like to deal with this situation.
you paid 5000, but shuold have only paid 4500 according to the new conditions.
as you dont want to change the conditions, it looks like you are okay with having paid 5000 and want valuate your receipt as well with this price. so your 5000 are gone at the end.
I would change the conditions.
you would receive and valuate your receipt at 4500, and you have still 500 credit left at the vendor which can be used for next delivery.
Maybe you are looking for
-
Hi all, The connection in SM59 , type T, with program id is not working. This program id refer to an interface that I developed in PI. I Put another program id in this connection and works. But my program id isn´t works. All Objects in Integration Bu
-
How can i Create a PROGRESSIVE BAR while process of a procedure is going
hi, I have a push button in my form that runs the procedure .the process will approx 15 minutes. while processing is started, i want to display PROGRESSIVE BAR until process complete and exits automatically after process . please suggest me how to cr
-
Have CS 5 Installed on my iMac and works ok. But installed on my new MacBook Pro it won't open NEF files from my Nikon D810. Displays NEF icons, but when I try and open them the response is: Make sure latest RAW updates are installed. If problem pers
-
I deleted time capsule files that were old, but now they won't delete from the trash
I deleted some time capsule files from the drive I am using for time machine. It placed them in the trash, but it won't delete them. It is asking if I want to delete only locked files or if I want to delete all files. I have tried both, but they a
-
I just got a MacBook less than a week ago, and so far there has been only one problem with it. When I try to watch a trailer on the Quicktime trailer site, no matter which one I choose (I haven't tried the HD ones), the picture is very distorted. The