Find parent/child relationships At More Than 2 Levels

Hello,
Does anyone have a solution to find parent/child relationship for data more than 2 levels deep?
I have a solution when there's a simple parent-child relationship but not when there's a grandparent-parent-child relationship or deeper.
Ex. I have a table company_parent_child that stores the relationship betwen a company and it's direct parent.
create table TEMP_COMPANY_PARENT_CHILD
PARENT_ID NUMBER(10),
COMPANY_ID NUMBER(10)
insert into TEMP_COMPANY_PARENT_CHILD values (1, 10);
insert into TEMP_COMPANY_PARENT_CHILD values (1, 11);
insert into TEMP_COMPANY_PARENT_CHILD values (1, 12);
insert into TEMP_COMPANY_PARENT_CHILD values (2, 13);
insert into TEMP_COMPANY_PARENT_CHILD values (10, 100);
insert into TEMP_COMPANY_PARENT_CHILD values (10, 101);
insert into TEMP_COMPANY_PARENT_CHILD values (10, 102);
insert into TEMP_COMPANY_PARENT_CHILD values (11, 103);
1->
___10->
______100,101,102,
___11->103
Companies 100, 101 and 102 are under parent 10 and grandparent 1.
I need to create such a view or another temp table so that when I pass the parent ID, I will pull all the children on all levels. In addition, and this is the tricky part, when I join this new temp table or view to another data table without any parameters, the data should not be duplicate, ie. each company ID should appear only once.
create table TEMP_JOIN
company_id number(10),
order_id varchar2(10)
insert into TEMP_JOIN values (100, 'a');
insert into TEMP_JOIN values (101, 'b');
insert into TEMP_JOIN values (102, 'c');
insert into TEMP_JOIN values (103, 'd');
insert into TEMP_JOIN values (10, 'e');
insert into TEMP_JOIN values (11, 'f');
insert into TEMP_JOIN values (12, 'e');
insert into TEMP_JOIN values (13, 'f');
Thanks.

start by learning CONNECT BY/START WITH. once you've
written a query to read the grandparent-parent-child
relationship, then come back with more questionsYes. we did look heavily into connect by/start with, in fact along with "connect_by_iscycle","connect_by_isleaf","connect_by_root" as well.
Our dilemma is that when a joint is made between those two tables mentioned above TEMP_COMPANY_PARENT_CHILD and TEMP_JOIN, we are not able to create a view that would contain distinct company_ids, each mapped to a unique order id.
The problem is we cannot have this type of joint when there are "n" level relationship between companies (or company_id). Basically, I think we should have our unique order id mapped to a unique key. This unique key should be a specialized key that we can know at anytime the entire path of the ancestry which we can know by sys_connect_by_path(company_id,'/') path.
How do we know which path to take. The best bet is to "connect_by_isleaf" and just have the distinct "deep" path which form the specialized unique key. If you need help on this let me know. (A hint, sort by LEVEL and then do a rank after partitioning by company id and then filter the records by rank = 1, try this one!!!)
So, we will eventually have a joint (say Table X) like
PATH ORDER_ID
/1/10/100 a
/1/10/101 b
/1/10/102 c
/1/10 e
/1
/1/11/103 d
/1/11 f
I think this is the best view we can have to maintain a joint with no repetition along PATH as well as ORDER_ID. If you have any other thoughts, let me know.
Then you query by path using INSTR to pull records by company_id.
for example, if you want to get all the children for company_id "10" you would just say
select * from X where INSTR(PATH,10,1,1) <> 0
or if you want to get all the children for company_id "11" you would just say
select * from X where INSTR(PATH,11,1,1) <> 0
What do you think? Has anyone used the path information for traversing the tree? Or is there any article that tells us how to make effective use of sys_connect_by_path(company_id,'/') path.
Thank you. Hope it made sense!

Similar Messages

  • Very  urgent- find parent-child relationship for wbs element

    Hi,
    There is a certain parent child heirachy in WBS elements.My requiremnet is to delete WBS element depending on certain field , say depending on some ""status"".If the status is active in some or any of the child then I am not suppose to delete its respective parent too. This parent-child relation can have say 5 levels.
    For this I require a logic /program which shall maintain the parent reference for that particular child whih I want/ dont want to delete.
    I am maintaining bottom- to -top approach.
    That is I shall be checking for the status of the lowest level of WBS and then  going to the highest.
    Please Help!
    Kshitija

    hi you can use following code....
    REPORT  zpmgmt_rpt_projinfo NO STANDARD PAGE HEADING LINE-SIZE  160.
    *& Includes
    INCLUDE <icon>.
    INCLUDE zdata_declare_n.  " include for data declaration
    INCLUDE zsubr_n.          " include for both subroutines
    DATA: gv_index LIKE sy-tabix,
          lv_index LIKE sy-tabix,
          date_index TYPE sy-tabix.
    *& Start of Selection ( Get Data )
    START-OF-SELECTION.
    For initial display cnt is set to X
      IF cnt EQ 'X'.
        PERFORM getdata.
        CLEAR it_final.
        PERFORM hierarchy.
        cnt = ''.
      ENDIF.
    *&      Form  GETDATA
    Fetches the data and logic for T1 and T2
    -->  p1        text
    <--  p2        text
    FORM getdata.
    Getting project header data
      SELECT * FROM proj
        INTO CORRESPONDING FIELDS OF TABLE it_proj
        WHERE pspid IN so_posid
        AND werks IN so_plant
        AND stort IN so_loc
        AND erdat IN so_date.
      IF sy-subrc <> 0.
        MESSAGE 'Enter the valid entry' TYPE 'I'.
        STOP.
      ENDIF.
      LOOP AT it_proj.
        PROJECT = it_proj-pspid.
    Get project & WBS element details
    BAPI used gives the output in some specific format
    which is used for roll-up logic.
        CALL FUNCTION 'BAPI_PROJECT_GETINFO'
         EXPORTING
            project_definition           = project
            with_activities              = 'X'
         IMPORTING
            e_project_definition         = e_project_definition
         TABLES
            e_wbs_hierarchie_table       = e_wbs_hierarchie_table.
    Appending all the projects in the e_wbs.
            LOOP AT e_wbs_hierarchie_table.
              MOVE-CORRESPONDING e_wbs_hierarchie_table TO e_wbs.
              APPEND e_wbs.
              CLEAR e_wbs.
            ENDLOOP.
        CLEAR PROJECT.
      ENDLOOP.
      SET COUNTRY 'US'.
      i_repid = sy-repid.
    Getting data into internal tables
    Getting project WBS element
      SELECT * FROM prps
        INTO CORRESPONDING FIELDS OF TABLE it_prps
        FOR ALL ENTRIES IN it_proj
        WHERE psphi = it_proj-pspnr.
    Getting project activities
      SELECT * FROM afvc
        INTO CORRESPONDING FIELDS OF TABLE it_afvc
        FOR ALL ENTRIES IN it_prps
        WHERE projn = it_prps-pspnr.
      SORT it_afvc BY vornr.
    Getting activities start & end dates from AFVV
      SELECT * FROM afvv
       INTO CORRESPONDING FIELDS OF TABLE it_afvv
       FOR ALL ENTRIES IN it_afvc
       WHERE aufpl = it_afvc-aufpl
       AND aplzl = it_afvc-aplzl.
    Getting plant name
      SELECT * FROM t001w
        INTO CORRESPONDING FIELDS OF TABLE it_t001w
        FOR ALL ENTRIES IN it_proj
        WHERE werks = it_proj-werks.
    Logic for passing data to final internal table
    Passing Project master data
      READ TABLE it_proj INDEX 1.
      IF sy-subrc EQ 0.
        CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
          EXPORTING
            input  = it_proj-pspid
          IMPORTING
            output = it_proj-pspid.
        it_final-posid = it_proj-pspid.
        it_final-post1 = it_proj-post1.
        APPEND it_final.
        CLEAR it_final.
      ENDIF.
    Passing WBS element to the final internal table IT_FINAL
      LOOP AT it_prps.
        CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
          EXPORTING
            input  = it_prps-posid
          IMPORTING
            output = it_prps-posid.
         CLEAR color.
    Get WBS element status ans color(T2)from OBJNR
        CALL FUNCTION 'ZGET_STATUS_N'
          EXPORTING
            objnr    = it_prps-objnr
          IMPORTING
            color    = color
          TABLES
            t_status = it_tj30t.
        IF     color = 'RED'.
          it_final-t2 = '@0A@'.
        ELSEIF color = 'YELLOW'.
          it_final-t2 = '@09@'.
        ELSEIF color = 'GREEN'.
          it_final-t2 = '@08@'.
        ENDIF.
        SORT it_tj30t DESCENDING.
    Getting User statuses of WBS element at component level.
        READ TABLE it_tj30t INDEX 1.
        IF sy-subrc EQ 0.
          CONCATENATE it_tj30t-txt04 '' INTO it_final-txt04 SEPARATED BY  space.
        ENDIF.
        READ TABLE it_tj30t INDEX 2.
        IF sy-subrc EQ 0.
          CONCATENATE it_tj30t-txt04 it_final-txt04 INTO it_final-txt04  SEPARATED BY space.
        ENDIF.
        MOVE-CORRESPONDING it_prps TO it_final.
        READ TABLE it_proj WITH KEY pspid = it_prps-posid.
        IF sy-subrc EQ 0.
          it_final-werks = it_proj-werks.
        ENDIF.
        APPEND it_final.
        CLEAR  it_final-txt04.
    Passing activity to the final internal table IT_FINAL
        LOOP AT it_afvc WHERE projn EQ it_prps-pspnr.
          CLEAR color.
    Getting user status and color(T2) for Activity from OBJNR
          CALL FUNCTION 'ZGET_STATUS_N'
            EXPORTING
              objnr    = it_afvc-objnr
            IMPORTING
              color    = color
            TABLES
              t_status = it_tj30t.
          IF     color = 'RED'.
            it_final-t2 = '@0A@'.
          ELSEIF color = 'YELLOW'.
            it_final-t2 = '@09@'.
          ELSEIF color = 'GREEN'.
            it_final-t2 = '@08@'.
          ENDIF.
          CLEAR: it_final-fsavd,
                 it_final-fssad.
          MOVE-CORRESPONDING it_afvc TO it_final.
    Getting User statuses of WBS element at activity level.
          SORT it_tj30t DESCENDING.
          READ TABLE it_tj30t INDEX 1.
          IF sy-subrc EQ 0.
            CONCATENATE it_tj30t-txt04 '' INTO it_final-txt04 SEPARATED  BY space.
          ENDIF.
          READ TABLE it_tj30t INDEX 2.
          IF sy-subrc EQ 0.
            CONCATENATE it_tj30t-txt04 it_final-txt04 INTO it_final-txt04  SEPARATED BY space.
          ENDIF.
          APPEND it_final.
          lv_index = sy-tabix.
          CLEAR it_final-txt04.
          CLEAR it_final-ltxa1.
          CLEAR it_tj30t.
          REFRESH it_tj30t.
    Start Date and End Date fetched from AFVV.
          LOOP AT it_afvv  WHERE   aufpl  EQ it_afvc-aufpl
                              AND   aplzl EQ it_afvc-aplzl.
            MOVE-CORRESPONDING it_afvv TO it_final.
            MODIFY it_final INDEX lv_index TRANSPORTING fsavd fssad.
          ENDLOOP.
          CLEAR it_afvc.
          CLEAR lv_index.
        ENDLOOP.
      ENDLOOP.
    Logic for T1.
    T1 is based on T2 and start date and end date of activities.
      LOOP AT it_final WHERE stufe = 3
                       AND ltxa1 IS NOT INITIAL.
        gv_index = sy-tabix.
        PERFORM date_difference.
        CASE it_final-t2.
          WHEN '@0A@'.     "  If Red
            IF sy-datum GT it_final-fssad.
              it_final-t1 = '@0A@'.
            ELSEIF sy-datum LE it_final-fssad AND
                   sy-datum GE it_final-fsavd.
              IF gv_diff > 1.
                PERFORM date_monitor.
              ENDIF.
              it_final-t1 = '@09@'.
            ELSEIF
              sy-datum LT it_final-fsavd.
              it_final-t1 = '@08@'.
            ENDIF.
          WHEN '@09@'.     " If Yellow
            IF sy-datum GT it_final-fssad.
              it_final-t1 = '@0A@'.
            ELSEIF sy-datum LE it_final-fssad AND
                   sy-datum GE it_final-fsavd.
              IF gv_diff > 1.
                PERFORM date_monitor.
              ENDIF.
              it_final-t1 = '@09@'.
            ELSEIF
              sy-datum LT it_final-fsavd.
              it_final-t1 = '@08@'.
            ENDIF.
          WHEN '@08@'.     " If Green
            it_final-t1 = '@08@'.
        ENDCASE.
        MODIFY it_final INDEX gv_index TRANSPORTING t1.
        CLEAR gv_index.
      ENDLOOP.
    ENDFORM.                    " GETDATA
    *&      Form  hierarchy
    Displays the data in ALV hierarchical manner.
    In coding 3 tables are used for roll-up functionality.
    FORM hierarchy .
      DATA: it_final1 LIKE it_final OCCURS 0 WITH HEADER LINE.
      DATA: it_final2 LIKE it_final OCCURS 0 WITH HEADER LINE.
      DATA: it_final3 LIKE it_final OCCURS 0 WITH HEADER LINE.
      DATA: count TYPE i VALUE 1.
      DATA: posid LIKE prps-posid.
      DATA: change,
            date_mask  TYPE c LENGTH 10,
            lv_index2 LIKE sy-tabix.
      DATA: index TYPE sy-tabix.
      DATA: up LIKE prps-posid.
    Deleting duplicate entries from the it_final.*****************
      DELETE ADJACENT DUPLICATES FROM it_final.
      LOOP AT it_final WHERE stufe EQ 2.
        IF posid NE it_final-posid.
          posid = it_final-posid.
        ELSE.
          DELETE it_final INDEX sy-tabix.
        ENDIF.
      ENDLOOP.
      CLEAR posid.
      LOOP AT it_final  WHERE stufe EQ 3
                        AND ltxa1 EQ space.
        IF posid NE it_final-posid.
          posid = it_final-posid.
        ELSE.
          DELETE it_final INDEX sy-tabix.
        ENDIF.
      ENDLOOP.
    Updating a new intrnal table for roll up functionality. ********
      it_final1[] = it_final[].
      CLEAR: lv_index2.
      LOOP AT it_final1 WHERE stufe =  3
                        AND ltxa1 IS NOT INITIAL.
        READ TABLE it_final WITH KEY  stufe = 3
                                      posid = it_final1-posid
                                      post1 = it_final1-post1.
       clear change.
        IF sy-subrc = 0.
          lv_index = sy-tabix.
          IF lv_index2 <> lv_index.
            CLEAR: change.
            lv_index2 = lv_index.
          ENDIF.
          IF it_final1-t1 = '@0A@'.
            it_final-t1 =  '@0A@' .
            MODIFY it_final INDEX lv_index TRANSPORTING t1.
            DELETE it_final1 WHERE posid = it_final-posid.
            CONTINUE.
          ENDIF.
          IF  it_final1-t1 = '@09@'.
            it_final-t1 = '@09@'.
            change = 'Y'.
            MODIFY it_final INDEX lv_index TRANSPORTING t1.
            CONTINUE.
          ENDIF.
          IF it_final1-t1 = '@08@'.
            it_final-t1 =  '@08@' .
            IF change IS INITIAL.
              MODIFY it_final INDEX lv_index TRANSPORTING t1.
            ENDIF.
            CONTINUE.
          ENDIF.
        ENDIF.
      ENDLOOP.
      it_final2[] = it_final[].
      CLEAR: lv_index2.
      LOOP AT it_final2 WHERE stufe = 3
                        AND ltxa1 IS INITIAL.
        READ TABLE e_wbs WITH KEY wbs_element = it_final2-posid.
        IF sy-subrc = 0.
          READ TABLE it_final WITH KEY stufe = 2
                                       posid = e_wbs-up.
          IF sy-subrc = 0.
            CHECK it_final-t1 <> '@0A@'.
            lv_index = sy-tabix.
            IF lv_index2 <> lv_index.
              CLEAR: change.
              lv_index2 = lv_index.
            ENDIF.
            IF   it_final2-t1 = '@0A@'.
              it_final-t1 =  '@0A@' .
              MODIFY it_final INDEX lv_index TRANSPORTING t1.
              CONTINUE.
            ENDIF.
            IF  it_final2-t1 = '@09@'.
              it_final-t1 = '@09@'.
              MODIFY it_final INDEX lv_index TRANSPORTING t1.
              change = 'Y'.
              CONTINUE.
            ENDIF.
            IF it_final2-t1 = '@08@'.
              it_final-t1 =  '@08@' .
              IF change IS INITIAL.
                MODIFY it_final INDEX lv_index TRANSPORTING t1.
              ENDIF.
              CONTINUE.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDLOOP.
      it_final3[] = it_final[].
      CLEAR: lv_index2.
      CLEAR change.
      LOOP AT it_final3 WHERE stufe = 2.
        READ TABLE e_wbs WITH KEY wbs_element = it_final3-posid.
        CHECK sy-subrc = 0.
        READ TABLE it_final WITH KEY stufe = 1
                                     posid = e_wbs-up.
        IF sy-subrc = 0.
          CHECK it_final-t1 <> '@0A@'.
          lv_index = sy-tabix.
          IF lv_index2 <> lv_index.
            CLEAR: change.
            lv_index2 = lv_index.
          ENDIF.
          IF   it_final3-t1 = '@0A@'.
            it_final-t1 =  '@0A@' .
            MODIFY it_final INDEX lv_index TRANSPORTING t1.
            DELETE it_final3.   " WHERE stufe = 2.
            CONTINUE.
          ENDIF.
          IF  it_final3-t1 = '@09@'.
            it_final-t1 = '@09@'.
            MODIFY it_final INDEX lv_index TRANSPORTING t1.
            change = 'Y'.
            CONTINUE.
          ENDIF.
          IF it_final3-t1 = '@08@'.
            it_final-t1 =  '@08@' .
            IF change IS INITIAL.
              MODIFY it_final INDEX lv_index TRANSPORTING t1.
            ENDIF.
            CONTINUE.
          ENDIF.
        ENDIF.
      ENDLOOP.
    Building hierarchy table ***************
      LOOP AT it_final.
        IF it_final-stufe = '0'.
          node_tab-type = 'T'.
          node_tab-name = 'Project'.
          node_tab-tlevel = '01'.
          node_tab-nlength = '8'.
          node_tab-color = '4'.
          node_tab-text = it_final-post1.
          node_tab-tlength ='20'.
          node_tab-tcolor = 5.
          APPEND node_tab.
          it_final_hsk-node = node_tab.
          APPEND it_final_hsk. CLEAR it_final_hsk.
          CLEAR node_tab.
        ELSEIF it_final-stufe = '1'.
          node_tab-type = 'P'.
          node_tab-name = 'Project'.
          node_tab-tlevel = '02'.
          node_tab-nlength = '10'.
          node_tab-color = '1'.
          node_tab-kind2 = 'I'.
          node_tab-text3+0(4) = it_final-t1.
          node_tab-tlength3 = '5'.
          node_tab-tcolor3 = 1.
          node_tab-kind3 = ' '.
          node_tab-text4 = it_final-posid.
          node_tab-tlength4 ='20'.
          node_tab-tcolor4 = 3.
    Code added for plant name
          CALL FUNCTION 'CONVERSION_EXIT_ABPSN_INPUT'
            EXPORTING
              input  = it_final-posid
            IMPORTING
              output = it_final-posid.
          READ TABLE it_proj WITH KEY pspid = it_final-posid.
          CHECK sy-subrc = 0.
          READ TABLE it_t001w WITH KEY werks = it_proj-werks.
          CHECK sy-subrc = 0.
    Code End.
          node_tab-kind4 = ' '.
          node_tab-text5 = it_t001w-name1.   " Plant Name
          node_tab-tlength5 ='25'.
          node_tab-tcolor5 = 4.
          node_tab-kind5 = ' '.
          node_tab-text6 = it_proj-stort.
          node_tab-tlength6 ='15'.
          node_tab-tcolor6 = 4.
          node_tab-kind6 = ' '.
          node_tab-text7 = it_final-post1.
          node_tab-tlength7 ='25'.
          node_tab-tcolor7 = 4.
          APPEND node_tab.
          it_final_hsk-node = node_tab.
          APPEND it_final_hsk. CLEAR it_final.
          CLEAR node_tab.
        ELSEIF it_final-stufe = '2'.
          node_tab-type = 'P'.
          node_tab-name = 'Gate Id'.
          node_tab-tlevel = '03'.
          node_tab-nlength = '10'.
          node_tab-color = '1'.
          node_tab-kind2 = 'I'.
          node_tab-text3+0(4) = it_final-t1.
          node_tab-tlength3 = '5'.
          node_tab-tcolor3 = 1.
          node_tab-kind3 = ' '.
          node_tab-text4 = it_final-posid.
          node_tab-tlength4 ='20'.
          node_tab-tcolor4 = 3.
          node_tab-kind4 = ' '.
          node_tab-text5 = it_final-post1.
          node_tab-tlength5 ='25'.
          node_tab-tcolor5 = 4.
          APPEND node_tab.
          it_final_hsk-node = node_tab.
          APPEND it_final_hsk.
          CLEAR it_final.
          CLEAR node_tab.
        ELSEIF it_final-stufe = '3' AND it_final-ltxa1 EQ space.
          node_tab-type = 'P'.
          node_tab-name = 'Component'.
          node_tab-tlevel = '04'.
          node_tab-nlength = '11'.
          node_tab-color = '1'.
          node_tab-kind2 = 'I'.
          node_tab-text3+0(4) = it_final-t1.
          node_tab-tlength3 = '5'.
          node_tab-tcolor3 = 1.
          node_tab-kind3 = ' '.
          node_tab-text4 = it_final-posid.
          node_tab-tlength4 ='25'.
          node_tab-tcolor4 = 3.
          node_tab-kind4 = ' '.
          node_tab-text5 = it_final-post1.
          node_tab-tlength5 ='25'.
          node_tab-tcolor5 = 4.
    Code added for start date and end date for component level.
          SELECT SINGLE pstrm petrf INTO (v_pstrm, v_petrf)
               FROM prte WHERE posnr = it_final-pspnr.
          it_final-fsavd = v_pstrm.
          it_final-fssad = v_petrf.
          MODIFY it_final INDEX sy-tabix.
          WRITE it_final-fsavd TO date_mask MM/DD/YYYY.
          node_tab-tpos1 = '0'.
          node_tab-kind5 = ' '.
          node_tab-text6 = date_mask.
          node_tab-tlength6 ='10'.
          node_tab-tcolor6 = 3.
          CLEAR date_mask.
          WRITE it_final-fssad TO date_mask MM/DD/YYYY.
          node_tab-tpos1 = '0'.
          node_tab-kind6 = ' '.
          node_tab-text7 = date_mask.
          node_tab-tlength7 ='10'.
          node_tab-tcolor7 = 3.
          CLEAR date_mask.
          APPEND node_tab.
          it_final_hsk-node = node_tab.
          APPEND it_final_hsk.
          CLEAR it_final_hsk.
          CLEAR node_tab.
        ELSEIF it_final-ltxa1 IS NOT INITIAL.
          node_tab-type = 'P'.
          node_tab-name = 'Element'.
          node_tab-tlevel = '05'.
          node_tab-nlength = '11'.
          node_tab-color = '1'.
          node_tab-kind = 'I'.
          node_tab-text1+0(4) = it_final-t1.
          node_tab-tlength1 = '5'.
          node_tab-tcolor1 = 1.
          node_tab-kind2 = 'I'.
          node_tab-text3+0(4) = it_final-t2.
          node_tab-tlength3 = '5'.
          node_tab-tcolor3 = 1.
          node_tab-kind3 = ' '.
          node_tab-text4 = it_final-ltxa1.
          node_tab-tlength4 ='45'.
          node_tab-tcolor4 = 3.
          node_tab-kind4 = ' '.
          node_tab-text5 = it_final-txt04.
          node_tab-tlength5 ='10'.
          node_tab-tcolor5 = 3.
          WRITE it_final-fsavd TO date_mask .
          node_tab-kind5 = ' '.
          node_tab-text6 = date_mask.
          node_tab-tlength6 ='10'.
          node_tab-tcolor6 = 3.
          CLEAR date_mask.
          WRITE it_final-fssad TO date_mask.
          node_tab-tpos1 = '0'.
          node_tab-kind6 = ' '.
          node_tab-text7 = date_mask.
          node_tab-tlength7 ='10'.
          node_tab-tcolor7 = 3.
          CLEAR date_mask.
          APPEND node_tab.
          it_final_hsk-node = node_tab.
          APPEND it_final_hsk.
          CLEAR it_final_hsk.
          CLEAR node_tab.
        ENDIF.
      ENDLOOP.
      CALL FUNCTION 'RS_TREE_CONSTRUCT'
        TABLES
          nodetab = it_final_hsk.
      CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
        EXPORTING
          callback_program      = i_repid
          callback_user_command = 'USER_COMMAND'
          callback_gui_status   = 'ZLD_TREE_N'
          screen_start_column   = 0
          use_control           = 'L'.
    ENDFORM.                    " hierarchy
    *&      Form  MYGUI
          text
         -->EX_TAB     text
    FORM zld_tree_n.
      SET PF-STATUS 'ZLD_TREE_N'.
    ENDFORM.                    "zld_tree.
    **&      Form  user_command
        Code for REFRESH button
    FORM user_command TABLES   node STRUCTURE seucomm
                               USING ucomm CHANGING exit
                                        list_refresh.
      CASE ucomm.
        WHEN 'REFR' .
          CLEAR it_final.
          REFRESH it_final_hsk.
          REFRESH it_final.
          PERFORM getdata.
          CLEAR it_final.
          PERFORM hierarchy.
        WHEN 'BACK1'.
          LEAVE TO TRANSACTION 'ZCN41_N'.
      ENDCASE.
    ENDFORM.                    "user_command
    include.....
    *&  Include           ZDATA_DECLARE
    *& Tables used for the report
    TABLES: proj, prps, aufk, afvc, jest, tj30t, afvv, prte.
    *& Type Pools used
    TYPE-POOLS: slis, icon, fibs, stree.
    *& Class & Data defination
    CLASS DEFINATION
    CLASS cl_gui_resources DEFINITION LOAD.
    DATA DECLARATION
    DATA: g_lights_name TYPE lvc_cifnm VALUE 'LIGHT',
          pspid LIKE proj-pspid,
          l_pos TYPE i VALUE 1,
          gs_layout TYPE slis_layout_alv,
          color TYPE zcn41_color_n-color.
    DATA : cnt VALUE 'X'.
    DATA : i_repid TYPE sy-repid.
    DATA : t_node TYPE snodetext.
    DATA : node_tab LIKE t_node OCCURS 0 WITH HEADER LINE.
    DATA : gv_diff TYPE p, stort LIKE proj-stort.
    CONSTANTS: st_formname_top_of_page TYPE slis_formname
                                  VALUE 'TOP_OF_PAGE-ALV'.
    *& Internal Table Declarations
    DATA it_proj   TYPE STANDARD TABLE OF proj WITH HEADER LINE.
    DATA it_prps   TYPE STANDARD TABLE OF prps WITH HEADER LINE.
    DATA it_afvc   TYPE STANDARD TABLE OF afvc WITH HEADER LINE.
    DATA it_tj30t  TYPE STANDARD TABLE OF tj30t WITH HEADER LINE.
    DATA it_afvv   TYPE STANDARD TABLE OF afvv WITH HEADER LINE.
    DATA it_jcds   TYPE STANDARD TABLE OF jcds WITH HEADER LINE.
    DATA it_t001w  TYPE STANDARD TABLE OF t001w WITH HEADER LINE.
    DATA: BEGIN OF it_final OCCURS 0,
              stufe  LIKE prps-stufe,
              pspnr  LIKE prps-pspnr,
              t1      TYPE icon-id,
              t2      TYPE icon-id,
              node    LIKE node_tab,
              posid  LIKE prps-posid,
              post1  LIKE prps-post1,
              ltxa1  LIKE afvc-ltxa1,
              txt04(20),
              objnr  LIKE afvc-objnr,
              vornr  LIKE afvc-vornr,
              aufpl  LIKE afvc-aufpl,
              aplzl  LIKE afvc-aplzl,
              fsavd  LIKE afvv-fsavd,  "Ear. Start date
              fssad  LIKE afvv-fssad,  "Ear. finish date
              werks  LIKE t001w-name1,     " added after update
              stort  LIKE proj-stort,     " added after update
         END OF it_final.
    DATA: BEGIN OF it_hsk OCCURS 0,
            t2      TYPE icon-id,
            t1      TYPE icon-id,
            posid  LIKE prps-posid,
            post1  LIKE prps-post1,
            objnr  LIKE afvc-objnr,
            stufe  LIKE prps-stufe,
          END OF it_hsk.
    DATA: BEGIN OF it_new OCCURS 0,
            objnr LIKE afvc-objnr,
            fsavd LIKE afvv-fsavd,
            fssad LIKE afvv-fssad,
            udate LIKE jcds-udate,
            t2(10),
          END OF it_new.
    CLEAR : node_tab, node_tab[].
    DATA  : entval TYPE prps-posid.
    DATA  : ct_fieldcat TYPE  slis_t_fieldcat_alv.
    DATA  : BEGIN OF it_final_hsk OCCURS 0,
              node LIKE node_tab,
            END OF it_final_hsk.
    DATA  : project LIKE bapipr-project_definition,
            e_project_definition LIKE bapi_project_definition_ex.
    DATA  : e_wbs_hierarchie_table TYPE STANDARD TABLE OF bapi_wbs_hierarchie
            WITH HEADER LINE.
    DATA  : e_wbs LIKE e_wbs_hierarchie_table OCCURS 0 WITH HEADER LINE.
    DATA:  v_pstrm LIKE prte-pstrm, v_petrf LIKE prte-petrf,
           v_posnr LIKE prps-pspnr.
    *& Selection Screen of the report
    SELECTION-SCREEN BEGIN OF BLOCK pms WITH FRAME TITLE text-001.
    SELECT-OPTIONS so_posid FOR proj-pspid OBLIGATORY.
    SELECT-OPTIONS so_plant FOR proj-werks.
    SELECT-OPTIONS so_loc FOR proj-stort.
    SELECT-OPTIONS so_date FOR sy-datum.
    SELECTION-SCREEN END OF BLOCK pms.
    *AT SELECTION-SCREEN .
    READ TABLE it_proj WITH KEY pspid = so_posid.
    IF sy-subrc <> 0.
       MESSAGE 'Project Name dose not exist' TYPE 'E.
    ENDIF.
    include..
    *&  Include           ZSUBR
    *&      Form  date_difference
          text
    -->  p1        text
    <--  p2        text
    FORM date_difference .
      CALL FUNCTION 'ZDATETIME_DIFFERENCE_N'
        EXPORTING
          date1                  = it_final-fsavd
          time1                  = '000000'
          date2                  = it_final-fssad
          time2                  = '000000'
       IMPORTING
         datediff               = gv_diff
       EXCEPTIONS
         INVALID_DATETIME       = 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.                    " date_difference
    *&      Form  date_monitor
          text
    -->  p1        text
    <--  p2        text
    T1 for more than 1 days activities
    Subroutines result out the T1 on basis of 80% of activity ( Green )
    or if 20 % reamined. ( Yellow )
    FORM date_monitor .
      DATA: date TYPE string,
            temp_date TYPE string,
            lv_date LIKE afvv-fsavd,
            lv_date_final LIKE afvv-fsavd,
            lv_days LIKE  bseg-dtws1 VALUE 0.
      CONSTANTS: con TYPE f VALUE '0.8'.
    *lv_date = it_new-fsavd.
      IF gv_diff EQ 2.
        lv_days = 1.
        CALL FUNCTION 'ZCALC_DATE_N'
          EXPORTING
            date      = it_final-fsavd
            days      = lv_days
            months    = '00'
            sign      = '+'
            years     = '00'
          IMPORTING
            calc_date = lv_date_final.
        IF sy-datum LE lv_date_final.
          it_final-t1 = '@08@'.
        ELSEIF sy-datum GT lv_date_final AND
               sy-datum EQ it_final-fssad.
          it_final-t1 = '@09@'.
        ENDIF.
      ELSEIF gv_diff > 2.
        lv_days = con * gv_diff.
        CALL FUNCTION 'ZCALC_DATE_N'
          EXPORTING
            date      = lv_date
            days      = lv_days
            months    = '00'
            sign      = '+'
            years     = '00'
          IMPORTING
            calc_date = lv_date_final.
        IF sy-datum LE lv_date_final.
          it_final-t1 = '@08@'.
        ELSEIF sy-datum GT lv_date_final AND
               sy-datum EQ it_final-fssad.
          it_final-t1 = '@09@'.
        ENDIF.
      ENDIF.
    ENDFORM.                    " date_monitor
    this code will give you exact out put as you required from bootom to top functinality....with status....

  • Hierarchical Query - Find Parent - Child relationship

    Table H (
    P -- PARENT
    C -- CHILD
    examples trees:
    1, 2, 3, 4, 5
    11, 22, 33, 44, 55
    111, 222, 333, 444, 555
    Given a list of Top Nodes, I need to create 1 or more trees. I need to identify nodes which may be a child of one of the other nodes and mark them invalid.
    Table TopNodes :
    id
    tn -- TopNode
    sample data: for TopNodes table
    4, 2, 33, 444
    For the above set
    4 : ERROR - child of 2
    2 : 2, 3, 4, 5
    33 : 33,44,55
    444 : 444, 555
    Can I accomplish in this in a query, or do i need to create a temp table and write a Procedure to figure this out ?

    Table H (
    P -- PARENT
    C -- CHILD
    examples trees:
    1, 2, 3, 4, 5
    11, 22, 33, 44, 55
    111, 222, 333, 444, 555
    Given a list of Top Nodes, I need to create 1 or more trees. I need to identify nodes which may be a child of one of the other nodes and mark them invalid.
    Table TopNodes :
    id
    tn -- TopNode
    sample data: for TopNodes table
    4, 2, 33, 444
    For the above set
    4 : ERROR - child of 2
    2 : 2, 3, 4, 5
    33 : 33,44,55
    444 : 444, 555
    Can I accomplish in this in a query, or do i need to create a temp table and write a Procedure to figure this out ?

  • Function to get the path using a parent-child relationship

    Hello,
    I have a table which uses parent-child relationship to store the options available. I need a function to give me the full path given the id of a particular option.
    I have two different functions. One of them uses the Oracle built in function and the other uses simple queries with a loop.The code of the functions are given below.
    Now, the problem is with their "performance". The difference in their performance is significant. The function using the Oracle function takes more than 2 hours to run a query whereas the other function takes less than 2 minutes.
    I am having trouble trusting the other function. No matter how many tests I perform on the output of both the functions, it always comes out to be the same.
    Any thoughts to help me understand this ??
    Function 1
    =====================
    FUNCTION Gettree (opt_id IN NUMBER,i_app_id IN NUMBER)
    RETURN VARCHAR2
    IS
    path VARCHAR2(32767);
    application_no NUMBER;
    BEGIN
    SELECT ABC.APP_OPT_ID INTO application_no FROM ABC
    WHERE ABC.APP_ID = i_app_id AND ABC.PARENT_ID IS NULL;
    SELECT LPAD(' ', 2*LEVEL-1)||SYS_CONNECT_BY_PATH(app_opt_name, '=>') "Path" INTO path
    FROM ABC
    WHERE app_opt_id = opt_id
    START WITH parent_id =application_no
    CONNECT BY PRIOR app_opt_id =parent_id;
    path := SUBSTR(path,INSTR(path,'>')+1,LENGTH(path));
    RETURN path;
    END Gettree ;
    Function 2
    ======================
    FUNCTION GetOptPath(opt_id NUMBER,app_id NUMBER)
    RETURN VARCHAR2
    IS
    string VARCHAR2(900);
    opt VARCHAR2(100);
    pid NUMBER(38);
    BEGIN
    SELECT ABC.parent_id,ABC.app_opt_name INTO pid,string FROM ABC WHERE ABC.app_opt_id = opt_id;
    IF pid IS NULL
    THEN
    RETURN 'root';
    ELSIF pid IS NOT NULL
    THEN
    LOOP
    SELECT ABC.app_opt_name,ABC.parent_id INTO opt, pid FROM ABC WHERE ABC.app_opt_id = pid;
    EXIT WHEN pid IS NULL;
    string := opt || '=>'|| string;
    END LOOP;
    RETURN string;
    END IF;
    END;

    Hi,
    user8653480 wrote:
    Hello Frank,
    The parameters taken by gettree & getoptpath are app_opt_id and app_id and both the functions return only one string i.e. the path of that particular option (app_opt_id) starting from its root and not all the descendants of that option/root node of that option.
    So, does that mean that gettree first fetches all the descendants of the root node of the given option and then returns the required one ??Yes. It's a little like the situation where you need to meet with your co-worker Amy, so you send an e-mail to everyone in the department telling them to come to your office, and then, when they arrive, tell everyone except Amy that they can leave.
    >
    And if that is the case, then won't it be better to use the bottom-up approach to fetch the required path just for that particular option ?? 'coz my requirement is that only.. given an option_id get the full path starting from the root.Exactly!
    I have used explain plan also for both the functions.. but since I did not know how to anlayze the output from plan_table so I just compared the value in the fields and they were exactly the same for both the queries.If you'd like help analyzing the plans, post them, as Centinul said.
    I am attaching a sample data with the outputs of both the functions for the reference.
    (tried attaching the file but could not find the option, so pasting the data here)
    App_opt_ID     App_ID     Parent_ID     App_opt_name     "gettree(app_opt_id,app_id)"     "getoptpath(app_opt_id,app_id)"
    1          1     NULL          application          NULL                    root
    2          1     1          module1               module1                    module1
    3          1     1          module2               module2                    module2
    4          1     2          submod1               module1=>submod1          module1=>submod1
    5          1     3          submod1               module2=>submod1          module2=>submod1
    6          1     5          opt1               module2=>submod1=>opt1          module2=>submod1=>opt1
    7          2     NULL          app2               NULL                    root
    8          2     7          scr1               scr1                    scr1
    9          2     8          opt1               scr1=>opt1               scr1=>opt1
    10          2     7          scr2               scr2                    scr2Please help.The best solution is to do a bottom-up query, and write a function like reverse_path (described in my first message) to manipulate the string returned by SYS_CONNECT_BY_PATH. You seem to have all the PL/SQL skills needed for this.
    Another approach is a revised form of gettree, like I posted earlier. Does it do what you want or not?
    If you'd help, then post a little sample data in a form people can actually use, such as CREATE TABLE and INSERT statements. Post a few sets of parameters, and the results you need from each set, given the sample data posted.

  • Help needed in retrieving parent child relationship values

    Hi,
    I have a requirement to get parent child relationship values as below.
    Ex: Address table
    cont cont_code state state_code
    C1 10 S1 1
    C1 10 S2 2
    C1 10 S3 3
    C2 20 S4 4
    C2 20 S5 5
    C3 30 S6 6
    C3 30 S7 7
    C3 30 S8 8
    I want a result of country/state and corresponding code like below.
    corresponding states should be displayed under each country with some space appended to it.
    Geography code
    C1 10
    S1 1
    S2 2
    S3 3
    C2 20
    S4 4
    S5 5
    C3 30
    S6 6
    S7 7
    S8 8
    I am using oracle 10g version.
    Thanks in advance.

    Hi,
    When you post formatted text (like your output) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    I think you're saying that you want this output:GEOGRAPHY CODE
    C1 10
    S1 1
    S2 2
    S3 3
    C2 20
    S4 4
    S5 5
    C3 30
    S6 6
    S7 7
    S8 8
    If so, UNION, as Hoek suggested, is a good way.
    GROUP BY ROLLUP is more efficient, but harder to understand:SELECT     CASE
              WHEN GROUPING (state) = 1
              THEN cont
              ELSE ' ' || state
         END          AS geography
    ,      CASE
              WHEN GROUPING (state) = 1
              THEN MAX (cont_code)
              ELSE MAX (state_code)
         END          AS code
    FROM     t
    GROUP BY cont
    ,      ROLLUP (state)
    ORDER BY cont
    ,      state          NULLS FIRST
    By the way, this looks like a bad table design.
    In a relational database, the fact that the name 'C1' belongs to cont_code 10 should only be stored in one place.  You have the same information on 3 separate rows.
    Also, if 'C1' and 'S1' are both names, they should probably be in the same column, so that (to give just one example) you can find the information about 'x1' without knowing if it is a cont or a state.
    A better design would be.NAME     CODE     PARENT     DSCR
    ====     ====     ======     ====
    C1     10          CONT
    S1     1     10     STATE
    S2     2     10     STATE
    S3     3     10     STATE
    C2     20          CONT
    S4     4     20     STATE
    S5     5     20     STATE
    C3     30          CONT
    S6     6     30     STATE
    S7     7     30     STATE
    S8     8     30     STATE
    If the data is this simple, then the dscr column isn't needed.  Whether parent is NULL or not tells whether the rows represents a cont or a state.
    To get the results you want from a table like this, you could use CONNECT BY.  Using either UNION or ROLLUP, you have to know, at the time you write the query, how many levels there will be in the parent-child tree, and the length of the code is proportional to that depth, and the table has to be changed if you ever need to add another level.  CONNECT BY can handle any number of levels, and the length and complexity of the code is the same whether you have just 2 levels (countries and strates), or 7 levels (continents, regions, countiries, states, districts, cities and neighborhoods) or 72 levels.  The table doesn't need any more columns, no matter how deep the tree gets.
    Edited by: Frank Kulash on Sep 16, 2010 11:54 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Re: Circular Parent-Child relationship amongwidgets.

    Alaiah,
    Setting the parent to NIL is the proper thing to do to remove
    a widget from a panel. Why don't you try just setting it
    to NIL and not adding the new chart to the window to make
    sure that it gets removed. If that doesn't work, maybe
    Window.UpdateDisplay, but you shouldn't have to do that.
    As far as the parent-child relationship issue, when you set
    the widget's Parent to NIL, that is actually invoking a virtual
    attribute that does more than just NIL out the reference. One
    of the things that happens is that the child is removed from
    the parent's Children array. Do a task.lgr.putline(<parent>.Children.Items)
    to see how many items are in the array, then do the NIL, then
    do a second putline and you'll see the array has one less item.
    Bobby
    At 06:10 PM 12/19/96 PST, Chandrashekar, Alaiah wrote:
    >
    I am trying to draw a Bar Graph on a panel which in turn sits on the main
    window. The height policy of the panel widget is set to SP_TO_PARENT so that
    when the window is resized the panel is also resized according to the parent
    window. I have a situation that every time the panel is resized I need to
    scale the Bar Graph in accordance with the new panel size and draw it. But
    before drawing the newly scaled Bar Graph I am clearing out all the children
    of the panel ( I am doing this just to refresh the panel) and then drawing
    the newly scaled Bar Graph. But this does not work!!! I still find some
    left over from the previous Bar Graph!!! Any help in this matter is greatly
    appreciated.
    Also I don't understand this circular parent-child relationship. If I assign
    a NIL to Parent attribute of all the children of the panel, what will happen
    to the Children attribute of the panel? Won't there be any memory leak by
    adopting the above procedure of disconnecting a child from its parent? If
    so, how do we take care of it?
    Thanks in advance!
    Alaiah Chandrashekar
    The following is the segment of the code which could be useful for clarity:
    // Draws the Bar Graph for the first time.
    self.ShowChart(TestData);
    self.Open();
    event loop
    when task.Shutdown do
    exit;
    // When the window is resized
    // I am scaling the Bar Graph for the new
    // panel size.
    when self.window.AfterReSize do
    self.ClearChartPanel();
    // self.window.UpdateDisplay();
    self.ShowChart(TestData);
    end event;
    self.Close();
    Method ClearChartPanel is as follows:
    for child in self.<ChartPanel>.Children do
    child.Parent = NIL;
    end for;

    Alaiah,
    Setting the parent to NIL is the proper thing to do to remove
    a widget from a panel. Why don't you try just setting it
    to NIL and not adding the new chart to the window to make
    sure that it gets removed. If that doesn't work, maybe
    Window.UpdateDisplay, but you shouldn't have to do that.
    As far as the parent-child relationship issue, when you set
    the widget's Parent to NIL, that is actually invoking a virtual
    attribute that does more than just NIL out the reference. One
    of the things that happens is that the child is removed from
    the parent's Children array. Do a task.lgr.putline(<parent>.Children.Items)
    to see how many items are in the array, then do the NIL, then
    do a second putline and you'll see the array has one less item.
    Bobby
    At 06:10 PM 12/19/96 PST, Chandrashekar, Alaiah wrote:
    >
    I am trying to draw a Bar Graph on a panel which in turn sits on the main
    window. The height policy of the panel widget is set to SP_TO_PARENT so that
    when the window is resized the panel is also resized according to the parent
    window. I have a situation that every time the panel is resized I need to
    scale the Bar Graph in accordance with the new panel size and draw it. But
    before drawing the newly scaled Bar Graph I am clearing out all the children
    of the panel ( I am doing this just to refresh the panel) and then drawing
    the newly scaled Bar Graph. But this does not work!!! I still find some
    left over from the previous Bar Graph!!! Any help in this matter is greatly
    appreciated.
    Also I don't understand this circular parent-child relationship. If I assign
    a NIL to Parent attribute of all the children of the panel, what will happen
    to the Children attribute of the panel? Won't there be any memory leak by
    adopting the above procedure of disconnecting a child from its parent? If
    so, how do we take care of it?
    Thanks in advance!
    Alaiah Chandrashekar
    The following is the segment of the code which could be useful for clarity:
    // Draws the Bar Graph for the first time.
    self.ShowChart(TestData);
    self.Open();
    event loop
    when task.Shutdown do
    exit;
    // When the window is resized
    // I am scaling the Bar Graph for the new
    // panel size.
    when self.window.AfterReSize do
    self.ClearChartPanel();
    // self.window.UpdateDisplay();
    self.ShowChart(TestData);
    end event;
    self.Close();
    Method ClearChartPanel is as follows:
    for child in self.<ChartPanel>.Children do
    child.Parent = NIL;
    end for;

  • Circular Parent-Child relationship among widgets.

    I am trying to draw a Bar Graph on a panel which in turn sits on the main
    window. The height policy of the panel widget is set to SP_TO_PARENT so that
    when the window is resized the panel is also resized according to the parent
    window. I have a situation that every time the panel is resized I need to
    scale the Bar Graph in accordance with the new panel size and draw it. But
    before drawing the newly scaled Bar Graph I am clearing out all the children
    of the panel ( I am doing this just to refresh the panel) and then drawing
    the newly scaled Bar Graph. But this does not work!!! I still find some
    left over from the previous Bar Graph!!! Any help in this matter is greatly
    appreciated.
    Also I don't understand this circular parent-child relationship. If I assign
    a NIL to Parent attribute of all the children of the panel, what will happen
    to the Children attribute of the panel? Won't there be any memory leak by
    adopting the above procedure of disconnecting a child from its parent? If
    so, how do we take care of it?
    Thanks in advance!
    Alaiah Chandrashekar
    The following is the segment of the code which could be useful for clarity:
    // Draws the Bar Graph for the first time.
    self.ShowChart(TestData);
    self.Open();
    event loop
    when task.Shutdown do
    exit;
    // When the window is resized
    // I am scaling the Bar Graph for the new
    // panel size.
    when self.window.AfterReSize do
    self.ClearChartPanel();
    // self.window.UpdateDisplay();
    self.ShowChart(TestData);
    end event;
    self.Close();
    Method ClearChartPanel is as follows:
    for child in self.<ChartPanel>.Children do
    child.Parent = NIL;
    end for;

    Hello Evandro,
    I am listing the steps to create a relationship manually.
    1. Create 2 records in the relationship table in console, one for "Married to" and the other one for "Owner". In order to do that the repository needs to be unloaded.
    2. Once you create these 2 records in the table through console, load the repository.
    3. Log on to the Data Manager.
    4. Now as per your example, there are 3 records in the main table, namely
         JOHN
         MARY
         ACME
    5. Select only one record in the record list area e.g. JOHN (where you see the list of records)
    6. Then, in the record edit area, double click on the relationship tab,
    7. New Window opens up.
    8. HERE ALL THE OPTIONS ARE GRAYED OUT. But Select the relationship which you want to create, in our case married to.
    9. Now select the record MARY in the record list area. (NOT in the pop window, but main window).
    10. Then on the top bar menu, select Relationships --> Adds to Group.
    11. Now close the Pop window and observe that the relationship has been created between JOHN and MARY.
    Let me know if it worked for you. if not, post some more information about your problem such as where you tried to configure and what options were grayed out.
    Please update.
    Thanks
    Shai
    I need to do a relationship among the BP where each record in Main Table correspond a BP (Person or Organization).
    The relationship should link the BPs as shown below:
    Records
    1; John
    2; Mary
    3; ACME
    In record 1, I need to say that John is married with Mary, where Married is a type of the relationship and that Mary is Owner of the ACME, where u201COwneru201D is other relationship type.
    I have tried to configure a Relationship (where the parent and child tables were the Main Table) in MDM, but I couldnu2019t to do it because the screen for this feature was locked. I need to be certified that the child link exist in the repository.
    Thank you.
    Evandro.

  • Reverse Engineering fails to "identify" parent - child relationship

    Using Reverse Engineering I obtained two classes - visual compapesence clearly shows that one is inherited from another.
    I wish I could copy and paste individual "class Diagrams' for each of those two to demonstrate my point ...
    How I could merge those two class diagrams together and "force"
    to recognize "parent" <-> child relationship /

    On possible solution is to create a diagram in each pacakge that was reverse engineered.
    I agree with peter, that a single diagram would not be useful when revese engineering a large project. When diagram get that large, it is hard to see more than a couple of model elements at one time. While we do have the Navigate Link tool, it is still painful to navigate around the diagram. If you printed a diagram that big, it would take up an entire wall.
    It is hard to determine what diagrams are needed to explain a software project. For this reason, we have tried to make it easy to build diagrams. Peter, mentioned the first mechanism. Create Diagram From Selected (CDFS) was designed to allow the user to select the model elements that need to populate a diagram. When performing CDFS the diagram will be populated, Relationship Discovery will be executed, and the diagram will be layed out.
    Another approach is to create a dependency diagram. You can select a model element, and create a dependency diagram. The contents of a dependency diagram will be the model elements that the selected model element uses. For example, if the model element generalizes from another model element, the super class will be present on the diagram. If another model elements extends the selected model element, the subclass will not be represented on the dependency diagram.
    Another diagram creation tool that might be needed is a inheritance diagram creator. An inheritance diagram creator, would make it very easy to see model element super classes, implemented interfaces, and the subclasses.
    I hope this helps.

  • Parent child relationship is not displaying for IDOC_OUTPUT_ORDERS (PO)

    Hi,
    Can somebody help me the reason why parent child relationship not displaying properly for ORDER05 basic type?
    If we go in details about the problem, a purchase order is creating in R/3 through EBP. To modify my requirement I am using userexit EXIT_SAPLEINM_002. Here I am appending the records in the segment for E1EDKT1 and E1EDKT2. IDOC is creating with an error of status record 26.
    When I check in the transaction WE19 for the respective IDOC the data is showing correctly for all the segments including e1edkt1 and e1edkt2 segments and also I check in the table EDID4 segment number is showing correctly and the for the segment E1EDKT2 PGNUM also showing correctly, but when I see the IDOC in the transactions WE02 unable to see parent child relationship between E1EDKT1 and E1EDKT2 segment. Simply the data is displaying one below other like other segment.
    I don't know the reason why it is displaying like that?
    If anybody is having the solution is highly appreciable.
    Regards,
    Noorul

    hi hassan,
    When you are appendng the REcods which belong to the purticular segment..
    all the segment needs to be appended in in the proper order as in the WE30..
    I<b> think you are appending the segment E1EDKT2 at the end of the EDIDD.. or IDOC_DATA in the user exit..</b> .. eventho no eerror will be displayed but idoc will generted with sataus 26 .. if check the <b>STATUIs Recored u ewill find the SYNTaX ERROR.</b>
    <b>Sollution for ur probelm is</b>... don append the E1EDKT2 at the lastr instead <b>you ahve to insert the segment E1EDKT2. only afer E1EDKT1..</b>..
    Tehn you r problem will be solved.. I had faced the Same proble when i worked on material maser idoc..
    <b>Close this thread if when u r problem ise solved</b>
    Reward if helpful
    Regards
    Naresh Reddy K

  • Parent Child Relationships between Drop Down Menus

    I  have a request for additional functionality.  Parent child relationships between drop down lists.
    for example,
    the first dropdown, could contain North, South, East, West & assign values of 1, 2, 3, 4.
    the second dropdown, could contain a filtered set of data depending on the option from the first dropdown,
    so the data could look like this in the second drop down:
    Manchester 1
    Leeds 1
    London 2
    Southampton 2
    Norfolk 3
    Newquay 4
    so if I select North in the first dropdown, the second drop down would contain all the items with a value of 1, so Manchester & Leeds.
    I have managed  to get round this using conditional show & hide, but it is much  messier on the design screen & also the way in which the data
    will be returned is very very messy - seems like a simple addition which would improve the functionality  no end.

    Hi,
    We have an "ideas" page where you can see if others have added this already, I believe there are some similar, and you can add your vote.  If you don't find something that fits you can add your idea here:
    http://forums.adobe.com/community/formscentral?view=idea
    Thanks,
    Josh

  • EJB 3, OneToMany that Acts As Tree, or Parent Child relationship support?

    (Sorry for the RoR reference)
    I first searched the forum and found this post that came close, but not exactly what I'm needing since my table doesn't reference the PK:
    http://forum.java.sun.com/thread.jspa?forumID=13&threadID=767913
    I have a table called Folder that represents a folder hierarchy. It has a 'Path' field and a 'Parent' field, and of course 'ID'. Each Folder knows its parent by the 'Parent' field, which references 'Path', not* 'ID'. Both are Strings.
    To find all the children of a Folder, the sql for a PreparedStatment might look something like this (shared for clarity of the situation):
    SELECT * FROM Folder
    WHERE Parent = ?Question:
    What are the proper annotations in EJB 3 / JPA to allow this kind non-primary key parent/child relationship mapping?
    Can I specify a named query that handles the logic and then reference it in the OneToMany annotation? Other cool tricks?
    Here is what I am trying (no runtime errors, but no results either). (Example simplified)
    @Entity
    @Table(name = "Folder")
    @NamedQueries(value = {@NamedQuery(.......)})
    public class Folder implements Serializable {
        @Id
        @Column(name = "ID", nullable = false, updatable = false)
        private Integer folderID;
        @Column(name = "Path", nullable = false)
        private String path;
        @Column(name = "Parent")
        private String parent;
        // v Here's the kicker v
        @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
        @JoinTable(name="Folder",
            joinColumns={@JoinColumn(name="Parent")},
            inverseJoinColumns={@JoinColumn(name="Path")})
        private List<Folder> children;
        // getters and setters ....
    }Thanks!

    It looks like the relationship is bi-directional.
    Will this work...
    // Parent.java
    @Entity
    public class Parent implements java.io.Serializable {
    @Id
    public Long parentId;
    @OneToMany(cascade=CascadeType.PERSIST,mappedBy="parent")
    public Collection<Child> children;
    // Child.java
    @Entity
    public class Child implements java.io.Serializable {
    @Id
    public Long childId;
    @ManyToOne
    public Parent parent;  // target of mappedBy
    }Then, in your code (a session facade?), you'll create the parent first, create the children, then add the children to the parent. Your code is also responsible for maintaining the reference back to the parent.
    Parent p = new Parent();
    for(int i=0; i<10; i++) {
      Child c = new Child();
      p.children.add(c);
      c.parent = p;
    em.persist(p);

  • Custom IDoc Type missing segment parent/child relationships

    Hi.
    I copied the standard ORDERS05 IDoc type to a custom type and cut out quite a few segments.  My new IDoc type is setup with parent/child segment relationships, similar to many of the original relationships in ORDERS05. 
    When I use the standard FM IDOC_OUTPUT_ORDRSP to generate an IDoc, it's not creating with parent/child segment relationships.  It's placing the children at the same level as the parent. 
    Anyone know what I'm doing wrong?
    Thanks!
    Cal

    figured out the problem.  was missing a required segment used to establish the parent/child relationship.

  • Import Manager - Import Parent Child Relationships

    I have a parent child relationship set up in console.
    Kits / Parts.
    Has Required = No
    Has Quantity = No
    I am trying to import the data for the relationship links using Import Manager.
    The source is a Excel file.
    Item Number <Kits>       Item Number<Parts>
    ACC-123                               ACC-1234
    ACC-123                               ACC-555
    I mapped the Item Number Kits and Item Number Parts.
    When I import, I am getting the following error
    <b>Import failed. Failed to find the aggregation record from its field values.
    Source record no: 1</b>
    I am able to import the same record using Data Manager if the file format is Text.
    Any help is appreciated.
    Helpful answers will be duly rewarded

    The key field that you use to load the relationship must be defined as:
    Unique................Yes
    Display...............Yes
    Multilingual..........No
    My problem was that I had defined Model Number as multiligual. When I changed this setting and loaded with Update Indices the load worked.
    I have not found anywhere in the literature that talks about this restriction. You can create the relationship in the Console. You can load this type of relationship in Data Manager. You can not however load them in Import Manager.

  • Does table STPOX contain parent-child relationship between components

    Hello
    I need to get a list of components of SO BOM.
    FM CS_BOM_EXPL_KND_V1 exports an output table STPOX.
    Does this table contain parent-child relationship between components? If yes , can somebody tell me which fields contain parent child id.
    thanks

    Hi,
    STPOX is not a table, it is a structure & hence there is no storing of data in a structure. The table which stores this info is STPO.
    To get the link you can refer to STPO-STLNR & pass this value to MAST-STLNR, this way you can link the child with its parent.
    Regards,
    Vivek

  • How to use GL Parent Child relationships in Discoverer?

    Subject: How to used GL Parent Child relationships in Discoverer?
    How to use GL Parent Child relationships in Discoverer?
    Please let me know how to incorporate the parent -child relation ships exsiting in GL Accouting flexfield Segments in Discoverer for drill downs? we have GL - BIS views installed.
    How to create the specific Parent -child relationship hierarchies in Discoverer from the FND_* tables?
    Please help.
    Thanks.
    KS.

    Hi,
    I'm also trying to implement this. If you have come any further in solving this any hints would be much appreciated...
    regards,
    AJ

Maybe you are looking for

  • Executing same VI multiple times, sending/retrieving data

    I know how to execute a single vi multiple times using the invoke node/reentrant method.  But I am not sure how to send/get data the running vi's. A little background on my project.  I have to test up to 64 units for a long period of time.  When one

  • Getting rid of 3 words at top of page on Safari

    How can I get rid of 3 words at top of page left over from an earlier search on Safari?

  • Make a CSV using OPEN HUB including some nodes of a hierarchy

    Hi People: I have a requirement that needs to make a CSV using OPEN HUB DESTINATION in BI7. I'm taking the information of a virtual cube (SEM ).  However, I have the detail in 0CS_ITEM. In this Infobject there are some nodes that have to be displayed

  • Error during activation of text elements

    Hello All, I have a problem activating the text elements of a program. The text elements can be edited but can not be activated. It displays an error during activation prompt.I tried deleteing it and recreating but still does not work. Thanks in adva

  • Other options for emailed itunes gift card?

    I received an itunes gift card via email.  Unlike a physical gift card, it does not have a redemption code.  Just a 'redeem' button. I don't want to redeem this code.  I would like to gift it to someone else or perhaps sell it.  But I need a physical