Saturday, October 10, 2015

How to create the Hierarchical Tree in oracle forms?

-  2 ways to populate a hierarchical tree (1. Record Group, 2. Query Text)

1 - Create Record group
2- Create hierarchical tree item (Control Block)
                         - WHEN-TREE-NODE-SELECTED
                         - WHEN-TREE-NODE-ACTIVATED
3– Create data block
-----------------------------------------------------
1- Create Record group

select 1,level,ename,null,to_char(empno)from emp connect by prior empno = mgr start with mgr is null


SELECT STATUS, LEVEL, LABEL, ICON, VALUE FROM TABLE;

STATUS - Indicates the initiate status of the Node (Normally Value is 1).
LEVEL - This is a specific pseudo-column Derived from “CONNECT BY”.
LABEL -This is the visible label of the Node.
ICON - That contains the icon name of the Node (can be NULL).
VALUE -That contains the value of the Node.

------
2- Create hierarchical tree item (Control Block)
Add the trigger code @ WHEN-NEW-FORM-INSTANCE and WHEN-TREE-NODE-ACTIVATED


DECLARE
   vi_tree      item;
   vn_tree_rg   NUMBER;
BEGIN
   vi_tree      := FIND_ITEM ('TREE_BLK.EMP_TREE');
   vn_tree_rg   := POPULATE_GROUP ('EMP_TREE_RG');
   ftree.SET_TREE_PROPERTY ( vi_tree, ftree.record_group, 'EMP_TREE_RG');
EXCEPTION
   WHEN OTHERS
   THEN
      fnd_message.debug (SQLERRM);
END;
Add the trigger code @ WHEN-TREE-NODE-SELECTED

DECLARE
   vi_htree        item;
   vc_node_value   VARCHAR2 (100);
BEGIN
   vi_htree        := FIND_ITEM ('TREE_BLK.EMP_TREE');
   vc_node_value   := ftree.GET_TREE_NODE_PROPERTY ( vi_htree, :SYSTEM.trigger_node, ftree.node_value);
   SET_BLOCK_PROPERTY ( 'emp', default_where, 'EMPNO = ' || vc_node_value);
   GO_BLOCK ('EMP');
   EXECUTE_QUERY;
EXCEPTION
   WHEN OTHERS
   THEN
      fnd_message.debug (SQLERRM);
END;
3 – Create data block



then very simply u have tree form now

Yasser

1 comment:

  1. I just leave this comment here - maybe it helps someone:
    I nearly despaired with a FRM-47313 now. Cost me 2 hours of valueable time. Turns out, query was ok, but the semicolon at the end of the query caused all the trouble. Ah well ...

    ReplyDelete