Building Tree hierarchy Using nested loops and class cl_gui_column_tree

Hello gurus,
I want to create a tree report using custom container and class cl_gui_column_tree. I have read and understood the standard demo report which SAP has provided i.e. SAPCOLUMN_TREE_CONTROL_DEMO. But in this report all the levels nodes are created as constants and hardcoded. I want to create hierarchy using nested loops. For this i took one example of a hierarchy of VBAK-VBELN->VBAP-POSNR Like One sales order has many line items and each line item can have number of line items in billing plan.
I have done some coding for it.
FORM build_tree USING node_table TYPE treev_ntab
                                       item_table TYPE zitem_table.              " i created the zitem_table table type of mtreeitm in SE11.
  DATA: node TYPE treev_node,
             item TYPE mtreeitm.
  node-node_key = root.
  CLEAR node-relatkey.
  CLEAR node-relatship.
  node-hidden = ' '.
  node-disabled = ' '.
  CLEAR node-n_image.
  CLEAR node-exp_image.
  node-isfolder = 'X'.
  node-expander = 'X'.
  APPEND node TO node_table.
  item-node_key = root.
  item-item_name = colm1.
  item-class = cl_gui_column_tree=>item_class_text.
  item-text = 'Root'.
  APPEND item TO item_table.
  item-node_key = root.
  item-item_name = colm2.
  item-class = cl_gui_column_tree=>item_class_text.
  item-text = 'Amount'.
  APPEND item TO item_table.
  LOOP AT it_vbeln INTO wa_vbeln.
    node-node_key = wa_vbeln-vbeln.
    node-relatkey = root.
    node-relatship = cl_gui_column_tree=>relat_last_child.
    node-hidden = ' '.
    node-disabled = ' '.
    CLEAR node-n_image.
    CLEAR node-exp_image.
    node-isfolder = 'X'.
    node-expander = 'X'.
    APPEND node TO node_table.
    item-node_key = wa_vbeln-vbeln.
    item-item_name = colm1.
    item-class = cl_gui_column_tree=>item_class_text.
    item-text = wa_vbeln-vbeln.
    APPEND item TO item_table.
    item-node_key = wa_vbeln-vbeln.
    item-item_name = colm2.
    item-class = cl_gui_column_tree=>item_class_text.
    item-text = wa_vbeln-netwr.
    APPEND item TO item_table.
    LOOP AT it_posnr INTO wa_posnr.
    node-node_key = wa_posnr-posnr.
    node-relatkey = wa_vbeln-vbeln.
    node-relatship = cl_gui_column_tree=>relat_last_child.
    node-hidden = ' '.
    node-disabled = ' '.
    CLEAR node-n_image.
    CLEAR node-exp_image.
    node-isfolder = ' '.
    node-expander = ' '.
    APPEND node TO node_table.
    item-node_key = wa_posnr-posnr.
    item-item_name = colm1.
    item-class = cl_gui_column_tree=>item_class_text.
    item-text = wa_posnr-posnr.
    APPEND item TO item_table.
    item-node_key = wa_posnr-posnr.
    item-item_name = colm2.
    item-class = cl_gui_column_tree=>item_class_text.
    item-text = wa_posnr-netpr.
    APPEND item TO item_table.
    ENDLOOP.
  ENDLOOP.
ENDFORM.
Now this program compiles fine and runs till there is only one level. That is root->vbeln. But when i add one more loop of it_posnr it gives me runtime error of message type 'X'. The problem i found was uniqueness of item-item_name as all the sales order have posnr = 0010. What could be done? I tried giving item_name unique hierarchy level using counters just like stufe field in prps eg. 10.10.10, 10.10.20,10.20.10,10.20.20,20.10.10 etc.. etc.. but still i am getting runtime error when i add one more hierarchy using nested loop. Plz guide.
Edited by: Yayati6260 on Jul 14, 2011 7:25 AM

Hello all,
Thanks the issue is solved. The node key was not getting a unique identification as nodekey. I resolved the issue by generating unique identification for each level. Thanks all,
Regards
Yayati Ekbote

Similar Messages

  • Generally when does optimizer use nested loop and Hash joins  ?

    Version: 11.2.0.3, 10.2
    Lets say I have a table called ORDER and ORDER_DETAIL.
    ORDER_DETAIL is the child table of ORDERS .
    This is what I understand about Nested Loop:
    When we join ORDER AND ORDER_DETAIL tables oracle will form a 'nested loop' in which for each order_ID in ORDER table (outer loop), oracle will look for corresponding multiple ORDER_IDs in the ORDER_DETAIL table.
    Is nested loop used when the driving table (ORDER in this case) is smaller than the child table (ORDER_DETAIL) ?
    Is nested loop more likely to use Indexes in general ?
    How will these two tables be joined using Hash joins ?
    When is it ideal to use hash joins  ?

    Your description of a nested loop is correct.
    The overall rule is that Oracle will use the plan that it calculates to be, in general, fastest. That mostly means fewest I/O's, but there are various factors that adjust its calculation - e.g. it expects index blocks to be cached, multiple reads entries in an index may reference the same block, full scans get multiple blocks per I/O. It also has CPU cost calculations, but they generally only become significant with function / package calls or domain indexes (spatial, text, ...).
    Nested loop with an index will require one indexed read of the child table per outer table row, so its I/O cost is roughly twice the number of rows expected to match the where clause conditions on the outer table.
    A hash join reads the of the smaller table into a hash table then matches the rows from the larger table against the hash table, so its I/O cost is the cost of a full scan of each table (unless the smaller table is too big to fit in a single in-memory hash table). Hash joins generally don't use indexes - it doesn't use the index to look up each result. It can use an index as a data source, as a narrow version of the table or a way to identify the rows satisfying the other where clause conditions.
    If you are processing the whole of both tables, Oracle is likely to use a hash join, and be very fast and efficient about it.
    If your where clause restricts it to a just few rows from the parent table and a few corresponding rows from the child table, and you have an index Oracle is likely to use a nested loops solution.
    If the tables are very small, either plan is efficient - you may be surprised by its choice.
    Don't be worry about plans with full scans and hash joins - they are usually very fast and efficient. Often bad performance comes from having to do nested loop lookups for lots of rows.

  • ALV Tree Hierarchy using OOPS

    Hi all,
    I have developed a program for ALV Tree Hierarchy using OOPs.I followed the SAP demo program.I am not able to get the values in the output.Please can anyone guide me where to correct my program. I am placing the entire code so that you all can also debug and see what is wrong.
    *& Report  ZZHIERARCHY_TEST1
    REPORT  zzhierarchy_test1.
    DATA : alv_container TYPE REF TO cl_gui_custom_container,
           alv_tree      TYPE REF TO cl_gui_alv_tree,
           gt_fcat          TYPE lvc_t_fcat,
           gt_vbrk TYPE vbrk OCCURS 0.                             "Output Table
    DATA : gs_hirarchy_header TYPE treev_hhdr.
    START-OF-SELECTION.
    END-OF-SELECTION.
      CALL SCREEN 9100.
    *&      Module  STATUS_9100  OUTPUT
    MODULE status_9100 OUTPUT.
      SET PF-STATUS 'ALV_TREE'.
      IF alv_container IS INITIAL.
        PERFORM tree_dev.
      ENDIF.
    ENDMODULE.                 " STATUS_9100  OUTPUT
    *&      Form  tree_dev
          text
    FORM tree_dev .
      DATA lv_container_name(20) TYPE c.
      lv_container_name = 'ALV_TREE'.
      CREATE OBJECT alv_container
        EXPORTING
          container_name              = lv_container_name
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 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.
      CREATE OBJECT alv_tree
        EXPORTING
          parent                      = alv_container
          node_selection_mode         = cl_gui_column_tree=>node_sel_mode_single
          item_selection              = 'X'
          no_toolbar                  = ''
          no_html_header              = '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
          OTHERS                      = 8.
      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 build_hirarchy_header CHANGING gs_hirarchy_header.
      PERFORM buid_fieldcatalog.
      CALL METHOD alv_tree->set_table_for_first_display
        EXPORTING
          is_hierarchy_header = gs_hirarchy_header
        CHANGING
          it_outtab           = gt_vbrk               "Table Must be Empty
          it_fieldcatalog     = gt_fcat.
      PERFORM create_hierarchy.
      CALL METHOD alv_tree->frontend_update.
    ENDFORM.                    " tree_dev
    *&      Form  build_hirarchy_header
         <--P_GS_HIRARCHY_HEADER  text
    FORM build_hirarchy_header  CHANGING p_gs_hirarchy_header TYPE treev_hhdr.
      p_gs_hirarchy_header-heading   =  'Company Code'(001).
      p_gs_hirarchy_header-tooltip   =  'Comapny Code'(002).
      p_gs_hirarchy_header-width     =   35.
      p_gs_hirarchy_header-width_pix =   ''.
    ENDFORM.                    " build_hirarchy_header
    *&      Form  buid_fieldcatalog
    FORM buid_fieldcatalog .
      DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
         i_structure_name             = 'VBRK'
        CHANGING
          ct_fieldcat                  = gt_fcat
       EXCEPTIONS
         inconsistent_interface       = 1
         program_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.
      LOOP AT gt_fcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'NETWR'.
            ls_fcat-do_sum = 'X'.
            ls_fcat-h_ftype = 'MAX'.
        ENDCASE.
        MODIFY gt_fcat FROM ls_fcat.
      ENDLOOP.
    ENDFORM.                    " buid_fieldcatalog
    *&      Form  create_hierarchy
    FORM create_hierarchy .
      DATA : lt_vbrk TYPE TABLE OF vbrk,
             ls_vbrk TYPE vbrk.
      DATA : top_key     TYPE lvc_nkey,
             company_key TYPE lvc_nkey,
             bzirk_key   TYPE lvc_nkey.
      DATA : lv_bukrs     TYPE bukrs,
             lv_bukrs_prv TYPE bukrs,
             lv_bzirk     TYPE bzirk,
             lv_bzirk_prv TYPE bzirk.
      SELECT * FROM vbrk INTO TABLE lt_vbrk UP TO 500 ROWS.
      SORT lt_vbrk BY bukrs .
      CALL METHOD alv_tree->add_node
        EXPORTING
          i_relat_node_key     = ''
          i_relationship       = cl_gui_column_tree=>relat_last_child
          i_node_text          = 'Company Code'
        IMPORTING
          e_new_node_key       = top_key
        EXCEPTIONS
          relat_node_not_found = 1
          node_not_found       = 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.
      LOOP AT lt_vbrk INTO ls_vbrk.
        lv_bukrs = ls_vbrk-bukrs .
        lv_bzirk = ls_vbrk-bzirk .
        IF lv_bukrs <> lv_bukrs_prv.
          lv_bukrs_prv =  lv_bukrs.
          PERFORM add_node USING lv_bukrs
                                 top_key
                        CHANGING company_key.
        ENDIF.
        IF lv_bzirk <> lv_bzirk_prv.
          lv_bzirk_prv = lv_bzirk.
          PERFORM add_posnr USING lv_bzirk
                                  company_key
                         CHANGING bzirk_key.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " create_hierarchy
    *&      Form  add_node
         -->P_LV_BUKRS  text
         -->P_TOP_KEY  text
         <--P_COMPANY_KEY  text
    FORM add_node  USING    p_lv_bukrs    TYPE bukrs
                            p_top_key     TYPE lvc_nkey
                   CHANGING p_company_key TYPE lvc_nkey .
      DATA: l_node_text TYPE lvc_value,
            ls_vbrk TYPE vbrk.
      l_node_text = 'Company' .
      CALL METHOD alv_tree->add_node
        EXPORTING
          i_relat_node_key     = p_top_key
          i_relationship       = cl_gui_column_tree=>relat_last_child
          is_outtab_line       = ls_vbrk
          i_node_text          = l_node_text
        IMPORTING
          e_new_node_key       = p_company_key
        EXCEPTIONS
          relat_node_not_found = 1
          node_not_found       = 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.                    " add_node
    *&      Form  add_posnr
          text
         -->P_LV_POSNR  text
         -->P_COMPANY_KEY  text
         <--P_POSNR_KEY  text
    FORM add_posnr  USING    p_lv_bzirk    TYPE bzirk
                             p_company_key TYPE lvc_nkey
                    CHANGING p_bzirk_key   TYPE lvc_nkey.
      DATA ls_vbrk TYPE vbrk.
      CALL METHOD alv_tree->add_node
        EXPORTING
          i_relat_node_key     = p_company_key
          i_relationship       = cl_gui_column_tree=>relat_last_child
          is_outtab_line       = ls_vbrk
          i_node_text          = 'Sales District'
        IMPORTING
          e_new_node_key       = p_bzirk_key
        EXCEPTIONS
          relat_node_not_found = 1
          node_not_found       = 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.                    " add_posnr
    *&      Module  USER_COMMAND_9100  INPUT
    MODULE user_command_9100 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
      CALL METHOD alv_container->free.
      LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_9100  INPUT

    Check this forum there are many threads on this.

  • Nested Loop and Driving Table.

    In the documentation I read these (/B19306_01/server.102/b14211/optimops.htm#i82080).
    The optimizer uses nested loop joins when joining small number of rows, with a good driving condition between the two tables. You drive from the outer loop to the inner loop, so the order of tables in the execution plan is important.
    The outer loop is the driving row source. It produces a set of rows for driving the join condition. The row source can be a table accessed using an index scan or a full table scan. Also, the rows can be produced from any other operation. For example, the output from a nested loop join can be used as a row source for another nested loop join.>
    I need some help to understand the bold line, i.e. so the order of tables in the execution plan is important.
    There are various conflicting opinion about the driving table (some says smaller and some says larger table is good option) and unfortunately I did not understand any of those logic.
    I read these threads/blogs also.
    CBO (optimizer) nest-loop join question
    http://hoopercharles.wordpress.com/2011/03/21/nested-loops-join-the-smaller-table-is-the-driving-table-the-larger-table-is-the-driving-table/
    In practice, I have seen explain plan for select e.ename,d.dname
      2  from emp e, dept d
      3  where e.deptno=d.deptno; usages emp as driving table (I only understood part of Aman's logic that dept table access would be faster when there would be an index available over it and hence it is in the inner loop)
    Whereas, SQL> explain plan for
      2  select e.ename,d.dname
      3  from emp e, dept d
      4  where e.deptno=d.deptno
      5  and e.deptno=20; usages dept as driving table.
    I have use USE_NL_WITH_INDEX with LEADING hint to change it, but it is giving some adverse effect (sometimes with optimizer_mode ALL_ROWS it is ignoring the hint completely).
    so the order of tables in the execution plan is important. How can I determine it ? I have read Tom's effective oracle by design but there is also no solution.

    Not sure I quite understand the question.
    Both threads contain lots of useful information about the broad considerations in play and debunking any myths.
    I need some help to understand the bold line, i.e.
    "so the order of tables in the execution plan is important"I read this as meaning just what it says, i.e. read the execution plan carefully and that
    NESTED LOOP
      A
      Bis not the same as
    NESTED LOOP
      B
      AA 10053 trace would normally be quite verbose about it's considerations as to join order.

  • About how to build dynamic maps using jdeveloper 10g and mapviewer

    i follow the guidance (about how to build dynamic maps using jdeveloper 10g and oracle application server mapviewer) to write a jsp file,but error take palce ,i get information "Project: D:\jdev1012\jdev\mywork\WebMap\ViewController\ViewController.jpr
    D:\jdev1012\jdev\mywork\WebMap\ViewController\public_html\WebMap.jsp
    Error(12,37): cannot access class oracle.lbs.mapclient.taglib.MapViewerInitTag; file oracle\lbs\mapclient\taglib\MapViewerInitTag.class not found
    Error(12,190): cannot access class oracle.lbs.mapclient.taglib.MapViewerInitTag; file oracle\lbs\mapclient\taglib\MapViewerInitTag.class not found
    Error(12,102): cannot access class oracle.lbs.mapclient.taglib.MapViewerInitTag; file oracle\lbs\mapclient\taglib\MapViewerInitTag.class not found
    Error(12,28): cannot access class oracle.lbs.mapclient.MapViewer; file oracle\lbs\mapclient\MapViewer.class not found
    Error(12,40): cannot access class oracle.lbs.mapclient.MapViewer; file oracle\lbs\mapclient\MapViewer.class not found
    Error(13,37): cannot access class oracle.lbs.mapclient.taglib.MapViewerSetParamTag; file oracle\lbs\mapclient\taglib\MapViewerSetParamTag.class not found
    Error(13,198): cannot access class oracle.lbs.mapclient.taglib.MapViewerSetParamTag; file oracle\lbs\mapclient\taglib\MapViewerSetParamTag.class not found
    Error(13,106): cannot access class oracle.lbs.mapclient.taglib.MapViewerSetParamTag; file oracle\lbs\mapclient\taglib\MapViewerSetParamTag.class not found
    Error(14,37): cannot access class oracle.lbs.mapclient.taglib.MapViewerRunTag; file oracle\lbs\mapclient\taglib\MapViewerRunTag.class not found
    Error(14,188): cannot access class oracle.lbs.mapclient.taglib.MapViewerRunTag; file oracle\lbs\mapclient\taglib\MapViewerRunTag.class not found
    Error(14,101): cannot access class oracle.lbs.mapclient.taglib.MapViewerRunTag; file oracle\lbs\mapclient\taglib\MapViewerRunTag.class not found
    Error(15,37): cannot access class oracle.lbs.mapclient.taglib.MapViewerGetMapURLTag; file oracle\lbs\mapclient\taglib\MapViewerGetMapURLTag.class not found
    Error(15,200): cannot access class oracle.lbs.mapclient.taglib.MapViewerGetMapURLTag; file oracle\lbs\mapclient\taglib\MapViewerGetMapURLTag.class not found
    Error(15,107): cannot access class oracle.lbs.mapclient.taglib.MapViewerGetMapURLTag; file oracle\lbs\mapclient\taglib\MapViewerGetMapURLTag.class not found"
    can you help?
    greetings

    I found a lot of information in document 133682.1 on metalink.
    step by step example how to deploy a JSP business component application.

  • Can I build a database, using my Contacts and then email them?

    Can I build a database, using my Contacts and then email them?

    If you mean email them as a group you need to get a group messaging app first. If you mean email the database you need to take a screen shot and email the photo.

  • Using nested tables and varrays in Forms/Reports6i

    Hi! Could anybody give practical examples of applications based on nested tables and varrays in Forms/Reports6i.
    The possible schema of building user interface and so on.
    Thank you.
    [email protected]

    Hi,
    Varrays and nested tables are not supported within Forms6i and Reports6i. This means tare is no way to use it.
    Frank

  • Build 1D array using for loop

    Hi guys,
    I am testing out array. How do I create a 1D array of x-y using for loop?

    Nextal wrote:
    I am testing out array. How do I create a 1D array of x-y using for loop?
    OK, first of all you did not say what the array should contain. If you want an array that has one array element for each iteration of the while loop, you need to first think a bit harder. Your outer loop has no wait, thus it will spin millions of times per second and you will run out of memory soon, no matter how much memory you have. How many times should the while loop iterate? If you know the number before the program starts, you would use a FOR loop and autoindex at the loop boundary.
    If you want to use a whiile loop, you need a mechanism to keep the array size reasonable. For small final arrays, you can just build the array in a shift register if you need it updated as it happens. If you only need the array after the loop stops, you can autoindex at the right loop boundary.
    In any case, you should take a step back and decide what you really want. Currently the specifications are very vague and unreasonable.
    LabVIEW Champion . Do more with less code and in less time .

  • How to create multi node /data Tree by using few loops or small code

    HI.
    I WANT TO CREATE A TREE WHICH IS HAVING MULTI NUMBER OF NODE LEVEL (USER HAVE THE ABILITY TO CREATE AS MANY AS REQUIRED NODE LEVEL OR SUBLEVEL). HOW CAN I POPULATE THE TREE WITH SMALL CODE. AS EVERY NODE LEVEL NEED ON NESTED LOOP. SO HOW CAN I MANAGE TO POPULATE THE NODE WITH FEW LOOPS. OR THERE IS ANY OTHER WAY TO MANAGE THIS PROBLEM.
    THANKS

    Hi ,
    I am trying to do the job , but i do not understand where
    is the problem with my loop , i am sending it , could you
    see it , and sujjest me , what to do. or if you have time
    can you write the code for me. as i am very much needy for
    this job.
    The Table is as:-
    CREATE TABLE TREE_01(
    RECORD_NO NUMBER(10), --
    OWN_CODE VARCHAR2(10),
    PARENT_NO NUMBER(10),
    PARENT_CODE VARCHAR2(10),
    LEVELL NUMBER(4),
    DEPT NUMBER(6),
    CONSTRAINT RNO_PK PRIMARY KEY(RECORD_NO));
    INSERT INTO TREE_01 VALUES(1,'1',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(2,'2',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(3,'3',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(4,'4',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(5,'1',1,'0',3,8540);
    INSERT INTO TREE_01 VALUES(6,'2',1,'0',3,8540);
    INSERT INTO TREE_01 VALUES(7,'3',1,'0',3,8540);
    INSERT INTO TREE_01 VALUES(8,'1',3,'0',3,8540);
    INSERT INTO TREE_01 VALUES(9,'2',3,'0',3,8540);
    the loop shoud look like
    |_DataProcessing
    | |+Work_orders
    | |_Programmers File
    | | |_James
    | | | |+Requests
    | | | |+Leves
    | | | |_Projects
    | | | |_Projects001
    | | |+Steven
    |+HealthCare
    |+Transportation
    So the loop should be such that it can be go to any level of any node.
    the Code i writter is As follows.
    The Following Procedure is called in form leve
    When new forms instance.
    PROCEDURE REFRESH_TREE2 IS
    CURSOR CUR_DEPT IS
         SELECT DEPT
         FROM TREE_01 GROUP BY DEPT;
    CURSOR CUR_LOOP1(PARENT1 NUMBER,LEVEL1 NUMBER) IS
         SELECT RECORD_NO,
         OWN_CODE,
         PARENT_NO,
         DEPT ,
         PARENT_CODE,
         LEVELL
         FROM TREE_01
         WHERE LEVELL=LEVEL1
         AND RECORD_NO=PARENT1;
    CURSOR CUR_LOOP2(PARENT2 NUMBER,LEVEL2 NUMBER) IS
         SELECT RECORD_NO,
         OWN_CODE,
         PARENT_NO,
         DEPT ,
         PARENT_CODE,
         LEVELL
         FROM TREE_01
         WHERE LEVELL=LEVEL2
         AND RECORD_NO=PARENT2;
    CURSOR LEVEL(PARENTNO NUMBER) IS
         SELECT LEVELL FROM TREE_01 WHERE PARENT_NO=PARENTNO
         ORDER BY RECORD_NO;
         V_I NUMBER;
         V_IGNORE NUMBER;
         RG_DEPT RECORDGROUP;
         RG_CABI RECORDGROUP;
         V_INIT_STATE GROUPCOLUMN;
         V_LEVEL GROUPCOLUMN;
         V_LABEL GROUPCOLUMN;
         V_ICON GROUPCOLUMN;
         V_VALUE GROUPCOLUMN;
         V_CHANGE_VALUE VARCHAR2(20);
         V_CHANGE_VALUE1 NUMBER(3);
         V_CHANGE_VALUE2 NUMBER(3);
    V_LEVEL_COUNT NUMBER;
    BEGIN
         SELECT MAX(LEVELL) INTO V_LEVEL_COUNT FROM TREE_01;
         RG_DEPT:=FIND_GROUP('DEPT');
         if not id_null(RG_DEPT) then
    delete_group(RG_DEPT);
    end if;
         RG_DEPT:=create_group('DEPT');
         V_INIT_STATE := add_group_column(RG_DEPT, 'INIT_STATE', NUMBER_COLUMN);
         V_LEVEL :=ADD_GROUP_COLUMN(RG_DEPT,'LEVEL',NUMBER_COLUMN);
         V_LABEL :=ADD_GROUP_COLUMN(RG_DEPT,'LABEL',CHAR_COLUMN,40);
         V_ICON :=ADD_GROUP_COLUMN(RG_DEPT,'ICON',CHAR_COLUMN,20);
         V_VALUE :=ADD_GROUP_COLUMN(RG_DEPT,'VALUE',CHAR_COLUMN,15);
         V_I :=1;
         FOR DEPTREC IN CUR_DEPT LOOP
         ADD_GROUP_ROW(RG_DEPT,V_I);
         SET_GROUP_NUMBER_CELL(V_INIT_STATE,V_I,1);
         SET_GROUP_NUMBER_CELL(V_LEVEL ,V_I,1);
         SET_GROUP_CHAR_CELL(V_LABEL ,V_I,FILING.ELOOK_IT(11,0,DEPTREC.DEPT));--MAIN_MINOR));
         SET_GROUP_CHAR_CELL(V_ICON ,V_I,NULL);
         SET_GROUP_CHAR_CELL(V_VALUE ,V_I,TO_CHAR(DEPTREC.DEPT)); --MAIN_MINOR));
         V_I:= V_I +1;
         V_CHANGE_VALUE := DEPTREC.DEPT;
         FOR I IN 1..V_LEVEL_COUNT LOOP
         FOR DEPTREC1 IN CUR_LOOP1(V_CHANGE_VALUE,I) LOOP --MAIN_MINOR,I) LOOP
         ADD_GROUP_ROW(RG_DEPT,V_I);
         SET_GROUP_NUMBER_CELL(V_INIT_STATE,V_I,1);
         SET_GROUP_NUMBER_CELL(V_LEVEL ,V_I,I);
         SET_GROUP_CHAR_CELL(V_LABEL ,V_I,DEPTREC1.RECORD_NO);
         SET_GROUP_CHAR_CELL(V_ICON ,V_I,NULL);
         SET_GROUP_CHAR_CELL(V_VALUE ,V_I,DEPTREC1.RECORD_NO);
         V_I:= V_I +1;
         SELECT count(LEVELL) INTO V_CHANGE_VALUE1
    FROM TREE_01
    WHERE RECORD_NO=DEPTREC1.RECORD_NO
         AND PARENT_NO=DEPTREC1.PARENT_NO
         AND LEVELL=DEPTREC1.LEVELL;
         SELECT MAX(LEVELL) INTO V_CHANGE_VALUE2
         FROM TREE_01
         WHERE RECORD_NO=DEPTREC1.RECORD_NO
         AND PARENT_NO=DEPTREC1.PARENT_NO
         AND LEVELL=DEPTREC1.LEVELL;
              FOR j IN 1..V_CHANGE_VALUE1 loop
              FOR LVL IN LEVEL(DEPTREC1.RECORD_NO) LOOP
              FOR DEPTREC2 IN CUR_LOOP2(DEPTREC1.RECORD_NO, LVL.LEVELL) LOOP
         ADD_GROUP_ROW(RG_DEPT,V_I);
         SET_GROUP_NUMBER_CELL(V_INIT_STATE,V_I,1);
         SET_GROUP_NUMBER_CELL(V_LEVEL ,V_I,LVL.LEVELL);
         SET_GROUP_CHAR_CELL(V_LABEL ,V_I,DEPTREC2.RECORD_NO);
         SET_GROUP_CHAR_CELL(V_ICON ,V_I,NULL);
         SET_GROUP_CHAR_CELL(V_VALUE ,V_I,DEPTREC2.RECORD_NO);
         V_I:= V_I +1;
         V_CHANGE_VALUE := DEPTREC2.RECORD_NO;
                   end loop;
         end loop;
         END LOOP;
         END LOOP;
         END LOOP;
         END LOOP;
         ftree.set_tree_property('NAVIGATOR.NAV_DISPLAY',ftree.record_Group, rg_dept);
         end;

  • Nested loops and if statements

    I have four schemas with a problem category table "gppcat" that
    has problem categories and problem descriptions. I need to
    output these categories and descriptions to a csv file. while
    doing this I need to make sure I don't include duplicate
    records. I use schema 1 as a system of record. I want to select
    pcode "category" from schema 1 and loop through to compare each
    record in the other schemas and write each unique record once to
    the file. I have included the code I am writing. I son't have
    much experience in PL/SQL, I usually write in ABAP or Java so
    the looping and if logic may seem incongruent as I have never
    implemented this in PL/SQL before. Thanks in advance, all the
    answers I have gotten fomr this forum have been great.
    CURSOR C1
    IS
    SELECT PCODE, PDESC FROM gpcomp1.gppcat;
    CURSOR C2
    IS
    SELECT PCODE, PDESC FROM gpcomp2.gppcat;
    CURSOR C3
    IS
    SELECT PCODE, PDESC FROM gpcomp3.gppcat;
    CURSOR C4
    IS
    SELECT PCODE, PDESC FROM gpcomp4.gppcat;
    -- error handling routine. we will handle all file access errors
    -- and data access errors in this procedure err_processing
    PROCEDURE err_processing (p_errFileHandle UTL_FILE.FILE_TYPE,
    p_lineNum PLS_INTEGER,
    p_errText VARCHAR2)
    IS
    BEGIN
    lv_errorFile := UTL_FILE.FOPEN(p_errDir,p_errFile,'W');
    UTL_FILE.PUT_LINE( lv_errorFile, lv_initErrorLog );
    UTL_FILE.FFLUSH(lv_errorFile);
    UTL_FILE.FCLOSE(lv_errorFile);
    UTL_FILE.FCLOSE_ALL;
    END err_processing;
    -- Retreive data into cursors
    BEGIN
    catFileHandle := UTL_FILE.FOPEN(p_dirName,p_fileName,'W');
    Here we need to loop through 4 companies and write all Problem
    Codes (pcode) and
    Problem Descriptions (pdesc) without writing duplicates. In this
    case we are using
    the same logic in the old extract by using the US company as the
    driving table.
    We compare the pcode, record by record in eanch 4 companies.
    When we find a unique
    record we write it to the file.
    FOR catLine1 IN C1
    LOOP
         FOR catLine2 IN C2
         LOOP
         IF catLine2.pcode = catLine1.pcode THEN
         writeLine:= (catLine1.pcode) || ',' ||
    (catLine1.pdesc);
              UTL_FILE.PUT_LINE( catFileHandle, writeLine );
         ELSE
         writeLine:= (catLine2.pcode) || ',' ||
    (catLine2.pdesc);
              UTL_FILE.PUT_LINE( catFileHandle, writeLine );
         END IF;
         END LOOP;
         FOR catLine3 IN C3
         LOOP
         IF catline3.pcode = catLine1.pcode THEN
         writeLine:= (catLine1.pcode) || ',' ||
    (catLine1.pdesc);
              UTL_FILE.PUT_LINE( catFileHandle, writeLine );
         ELSE
         writeLine:= (catLine3.pcode) || ',' ||
    (catLine3.pdesc);
              UTL_FILE.PUT_LINE( catFileHandle, writeLine );
         END IF;
         END LOOP;
         FOR catLine4 IN C4
         LOOP
         IF catline4.pcode = catLine1.pcode THEN
         writeLine:= (catLine1.pcode) || ',' ||
    (catLine1.pdesc);
              UTL_FILE.PUT_LINE( catFileHandle, writeLine );
         ELSE
         writeLine:= (catLine4.pcode) || ',' ||
    (catLine4.pdesc);
              UTL_FILE.PUT_LINE( catFileHandle, writeLine );
         END IF;
         END LOOP;
         EXIT WHEN C1%NOTFOUND;
         UTL_FILE.PUT_LINE( catFileHandle, writeLine );
    END LOOP;
    UTL_FILE.FFLUSH(catFileHandle);
    UTL_FILE.FCLOSE(catFileHandle);
    Thanks again.
    -Pat

    The easiest way of doing this is to use the UNION operator.
    You just have one cursor, viz:
    CURSOR C1
    IS
    SELECT PCODE, PDESC FROM gpcomp1.gppcat
    UNION
    SELECT PCODE, PDESC FROM gpcomp2.gppcat
    UNION
    SELECT PCODE, PDESC FROM gpcomp3.gppcat
    UNION
    SELECT PCODE, PDESC FROM gpcomp4.gppcat;
    This will return only unique rows (to get duplicates you use
    UNION ALL). Then you can use a single CURSOR LOOP structure to
    write out the result set:
    FOR lrec IN C! loop
    utl_file.put_line(C1.pcode);
    END LOOP;
    HTH, APC

  • How to build tree/hierarchy/explorer format in internal table

    Dear Friends,
    I have one internal table with parent and child, again child will be acting as parent and it can have further childs ......
    like that it goes on there is no constant levels it goes on....
    for example.
    parent child
    100 101
    102
    103
    101 201
    202
    102 301
    103 401
    402
    403
    this has to be displayed in hierarchy mode.
    here i to as a column wich has to represent its position/level in the hierarchy like:
    1
    1.1
    1.1.1
    1.2
    1.2.1
    ......n
    1.2.2...n
    1.3
    2
    2.1
    2.2
    3
    etc...
    let me know any ideas to get the maping of the rows to put it in tree format( like windows explorer).
    Thanks,
    Mahesh.Gattu

    REPORT  Z_TREE.
    TYPE-POOLS: ICON.
    TYPE-POOLS : FIBS,STREE.
    INCLUDE <ICON>.
    DATA : T_NODE TYPE SNODETEXT.
    DATA : NODE_TAB LIKE T_NODE OCCURS 0 WITH HEADER LINE.
    DATA : ITAB LIKE VBAP OCCURS 0 WITH HEADER LINE.
    DATA : ITTX LIKE MAKT OCCURS 0 WITH HEADER LINE.
    DATA : LI TYPE I VALUE 1.
    CLEAR : NODE_TAB, NODE_TAB[].
    SELECT * FROM VBAP INTO TABLE ITAB UP TO 50 ROWS.
    SELECT * FROM MAKT INTO TABLE ITTX FOR ALL ENTRIES IN ITAB WHERE MATNR = ITAB-MATNR.
    NODE_TAB-TYPE = 'T'.
    NODE_TAB-NAME = ''.
    NODE_TAB-TLEVEL = '01'.
    NODE_TAB-NLENGTH = ''.
    NODE_TAB-COLOR = '3'.
    NODE_TAB-TEXT = 'ICON_DETAIL'.
    NODE_TAB-TCOLOR = '1'.
    NODE_TAB-KIND = 'I'.
    NODE_TAB-TLENGTH = '2'.
    NODE_TAB-TEXT1 = 'Details'.
    NODE_TAB-TCOLOR1 = '2'.
    NODE_TAB-KIND = 'I'.
    NODE_TAB-TLENGTH1 = '10'.
    APPEND NODE_TAB.
    CLEAR NODE_TAB.
    LOOP AT ITAB.
      AT NEW VBELN.
        NODE_TAB-TYPE = 'P'.
    *   node_tab-name = 'Sale Number'.
        NODE_TAB-TLEVEL = '02'.
    *   node_tab-nlength = '12'.
        NODE_TAB-TCOLOR = '4'.
        NODE_TAB-TEXT = ITAB-VBELN.
        NODE_TAB-TLENGTH ='10'.
        APPEND NODE_TAB.
        CLEAR NODE_TAB.
      ENDAT.
    READ TABLE ITTX WITH KEY MATNR = ITAB-MATNR.
      NODE_TAB-TYPE = 'P'.
    * node_tab-name = 'LI'.
      NODE_TAB-TLEVEL = '03'.
    * node_tab-nlength = '4'.
    NODE_TAB-TEXT = 'ICON_MATERIAL'.
    NODE_TAB-TCOLOR = '1'.
    NODE_TAB-KIND = 'I'.
    NODE_TAB-TLENGTH = '2'.
      NODE_TAB-TCOLOR1 = '5'.
      NODE_TAB-TEXT1 = ITAB-MATNR.
      NODE_TAB-TLENGTH1 = '20'.
      NODE_TAB-TCOLOR2 = '7'.
      NODE_TAB-TEXT2 = ITTX-MAKTX.
      LI = STRLEN( ITTX-MAKTX ).
      NODE_TAB-TLENGTH2 = LI.
      APPEND NODE_TAB.
      CLEAR NODE_TAB.
    *  READ TABLE ITTX WITH KEY MATNR = ITAB-MATNR.
    *  NODE_TAB-TYPE = 'P'.
    ** node_tab-name = 'LI'.
    *  NODE_TAB-TLEVEL = '03'.
    ** node_tab-nlength = '4'.
    *  NODE_TAB-TCOLOR1 = '7'.
    *  NODE_TAB-TEXT1 = ITTX-MAKTX.
    *  LI = STRLEN( ITTX-MAKTX ).
    *  NODE_TAB-TLENGTH = LI.
    *  APPEND NODE_TAB.
    *  CLEAR NODE_TAB.
    ENDLOOP.
    CALL FUNCTION 'RS_TREE_CONSTRUCT'
      TABLES
        NODETAB = NODE_TAB.
    *DATA: type_mapping TYPE stree_ctl_type_mapping_tab.
    *DATA: wa_type TYPE stree_ctl_type_mapping.
    *CLEAR: type_mapping[].
    *wa_type-type = 'A'.
    *wa_type-icon = '@BL@'.
    *APPEND wa_type TO type_mapping.
    CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
      EXPORTING
        STATUS      = 'STANDARD'
        USE_CONTROL = 'L'.

  • Performance impact using nested tables and object

    Hi,
    Iam using oracle 11g.
    While creating a package, iam using lot of nested tables created based on objects which will be passed between multiple functions in the package..
    Will it have any performance impact since all the data is stored in the memory.
    How can i measure the performance impact when the data grows ?
    Regards,
    Oracle User
    Edited by: user9080289 on Jun 30, 2011 6:07 AM
    Edited by: user9080289 on Jun 30, 2011 6:42 AM

    user9080289 wrote:
    While creating a package, iam using lot of nested tables created based on objects which will be passed between multiple functions in the package.. Not the best of ideas in general, in PL/SQL. This is not client code that can lay sole claim to most of the memory. It is server code and one of many server processes that need to share the available resources. So capitalism is fine on a client, but you need socialism on the server? {noformat} ;-) {noformat}
    Will it have any performance impact since all the data is stored in the memory.Interestingly yes. Usually crunching data in memory is better. In this case it may not be so. The memory used is the most expensive memory Oracle can use - the PGA. Private process memory. This means each process copy running that code, will need lots of memory.
    If you're not passing the data structures by reference, it means even bigger demands on memory as the data structure needs to be copied into the call stack and duplicated.
    The worse case scenario is that such code consumes so much free server memory, and make such huge demands on having that in pysical memory, it trashes memory management as the swap daemons are unable to keep up with the demand of swapping virtual memory pages into and out of memory. Most CPU time is spend by the swap daemons.
    I have seen servers crash due to this. I have seen a single PL/SQL process causing this.
    How can i measure the performance impact when the data grows ?Well, you need to look at the impact of your code on PGA memory. It is not SQL performance or I/O performance that is a factor - just how much private process memory your code needs in order to execute.

  • Building array within 2 nested fors and 2 nested cases

    Hi all,
    I can't seem to figure out why one of my arrays keeps getting reset.  What I need to do is disassemble my clusters one at a time check for an node address then packet and decode the hex data.  Data decodes will be different for every node.  When a node is decoded, I need to add that data to an array dedicated to that node.  When the entire cluster array is processed, the data will be dumped to different Excel sheets.  One sheet for each node on the system. This is a simplified version of a much larger program that will handle many nodes and lots of data.  Any help would be appreciated.
    --Mark
    Attachments:
    Building an Array 2 fors 2 case.vi ‏19 KB

    Your tunnels on the inner loop need to be shift registers as well.

  • Creating tabs using nested tables and templates

    Hello all - Hopefully everyone had a good Easter !
    is it possible to create a template of the tab structure i
    want, and then insert this new template and modify the colours for
    each different tab link / page link? ie, all the tabs will have the
    same links but will have different colours on different pages.
    you're welcome to jump on my website at
    http://www.bondimigration.com.au/overview_10.html
    to get an idea of what I'm talking about..

    Use a server-side include for the menu on each page, give
    each button a
    unique ID, and use a page-specific stylesheet (either linked
    or embedded) to
    change the style values for the selected button.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "dooner1" <[email protected]> wrote in
    message
    news:evg1bo$66e$[email protected]..
    > Hello all - Hopefully everyone had a good Easter !
    >
    > is it possible to create a template of the tab structure
    i want, and then
    > insert this new template and modify the colours for each
    different tab
    > link /
    > page link? ie, all the tabs will have the same links but
    will have
    > different
    > colours on different pages.
    > you're welcome to jump on my website at
    >
    http://www.bondimigration.com.au/overview_10.html
    to get an idea of what
    > I'm
    > talking about..
    >
    >

  • Preserving Folder Tree Hierarchy using Export Plugins in 2.0

    Hi Folks,
    I've been trying to find a plugin that will allow me to select a top level folder and then export all images preserving the folders / subfolders.
    i.e. Select 2008 and end up with export of all images in appropriate sub folders:
    2008\beach shoot
    2008\weekend shots
    2008\wooded area
    Anyone know if this is possible on 2.0 either natively or using a plugin ?
    Thanks
    Adam.
    [email protected]

    http://www.lightroomforums.net/showthread.php?t=2810
    Here is a solution.

Maybe you are looking for

  • TS4124 itunes match on a new hard drive

    i updated my hard drive and did not transfer all my music because im subscribed to itunes match. im able to see the music,but i cant play it or download it. can someone help.

  • I lose internet connectivity OFTEN. 2 times today. Anyone know why?

    I lose connectivity to the internet. It happens quite often. I use Firefox exclusively. When I lose the connection I have to go to Explorer and run the trouble shooter there. It finds the problem every time and I can reconnect using Firefox. Any idea

  • Nokia Lumia 2520 - No support email received?

    I'm wondering if someone could help me with figuring out why I didn't receive a support email back regarding my shipping details for my support case. Does anyone know an email or contact number for Nokia support so I can get that tracking info email

  • This is all I can get outta 1600+

    Have a 1600+ with k7n2l and this is best I can get. My memory is crucial pc2100. Should I get some better memory, pc2700 or better. Oh the chip is not unlocked. But I guess I really can't complain? 10.5x160

  • Can't get past the white screen at start up

    I can not get past the white screen when it starts up. It will chime and then stay at the white screen. I have replaced the hard drive, memory, battery. I have reset the PRAM and the SMC.