Increment Counter in Parent / Child

I am generating classes from an existing schema.
I have two tables that are Parent / Child with the parent containing an
incrementing counter that is part of the Child primary key.
Is there a way to describe this relationship so that the generated code has
the rationship properly described?

I have a parent table, 'CARD_HOLDER' that has a key of ID_CARDHOLDER
(integer) and a row of CURRENT_SEQ_NO (integer).
The child table, 'CARD' has a key of ID_CARDHOLDER (integer) and SEQ_NO
(integer) [both colums are the key value].
When a new card is added to the 'CARD' table, the CARDHOLDER.CURRENT_SEQ_NO
is incremented and the CARD.CURRENT_SEQ_NO is set equal to it.
Can I emulate this behavior in KODO?
When a new 'card'
"Abe White" <[email protected]> wrote in message
news:[email protected]..
Sorry, could you describe the table structure in more detail? I'm not
sure I follow.

Similar Messages

  • Parent Child count- so complicated!

    Hi Guys
    I have a dataset where there are parent and child products.
    Each parent has got a unique code(P1,p2 etc) and a link code (L1) on their account
    and each child of the parent has got a seperate code (C12) but they share the same account no.
    I want to count the parent and children
    Here is the ddl with the desired output.
    Pls help!!
    create table #Something
    Line_no int,
    code varchar(5),
    AccountNo char(5)
    insert #Something
    select 12311, 'P1c', 'Ac115' union all
    select 12311, 'L1', 'Ac115' union all
    select 123, 'C1', 'Ac115' union all
    select 1222, 'C1', 'Ac115' union all
    select 1243, 'C1', 'Ac115' union all
    select 433, 'P1a', 'Ac111' union all
    select 433, 'L1', 'Ac111' union all
    select 4331, 'C1', 'Ac111' union all
    select 543, 'C1', 'Ac222' union all
    select 544, 'C1', 'Ac222' union all
    select 4322, 'P1b', 'Ac222' union all
    select 4322, 'L1', 'Ac222' union all
    select 8766 'P1d' , 'Ab111' union all
    select 8766 'L1' , 'Ab111' union all
    select 8767 'C1', 'Ab111' union all
    select 8789 'P1d', 'Ab119' union all
    select 8766 'L1', 'Ab119' union all
    select 876654 'C1', 'Ab119' union all
    select 876655 'C1', 'Ab119' union all
    select 876698 'P1a', 'Ab117' union all
    select 876698 'L1', 'Ab117' union all
    select 987 'C1', 'Ab117' union all
    select 555444 'P1d' 'Xcv' union all
    select 555444 'L1' 'Xcv' union all
    select 6754 'C1' 'Xcv' union all
    select * from #Something
    drop table #Something
    Desired output is:
    [Parent code] [Parent line Count] [Child line Count]
    P1c 1 3
    P1a 2 2
    P1b 1 2
    P1d 3 4
    Thanks

    Hi Guys 
    just following on to my above question, there is a new challenge now.
    Along with counting the lines, I need to count the total plan changes as well within a month as any parent or child plan can change their plans within a month.
    in my current schema, there is a base table which is maintained at a daily level which shows all the active parent and child lines .
    In my migration table, it shows whether a parent or child has got any plan changes or not.
    Here is the ddl for Base table
    create table #base
    date datetime,
    Line_no int,
    code varchar(5),
    AccountNo char(5),
    select
    12311,
    'P1c',
    'Ac115'
    union
    all
    select 12311, 'L1', 'Ac115' union all
    select 123, 'C1', 'Ac115' union all
    select 1222, 'C1', 'Ac115' union all
    select 1243, 'C1', 'Ac115' union all
    select 433, 'P1a', 'Ac111' union all
    select 433, 'L1', 'Ac111' union all
    select 4331, 'C1', 'Ac111' union all
    select 543, 'C1', 'Ac222' union all
    select 544, 'C1', 'Ac222' union all
    select 4322, 'P1b', 'Ac222' union all
    select 4322, 'L1', 'Ac222'
    select * from #base
    drop table #base
    here is the new ddl for migration
    create table #Something
    date datetime,
    Line_no int,
    code varchar(5),
    AccountNo char(5),
    Plan_change int
    insert #Something
    select 01/02/2013  123, 'C1', 'Ac115'   1 union all
    select 02/02/2013 1222, 'C1', 'Ac115' 1      union all
    select 02/02/2013 1243, 'C1', 'Ac115' 1 union all
    select 03/03/2013 4331, 'C1', 'Ac111' 1 union all
    select 03/03/2013 543, 'C1', 'Ac222'  1 union all
    select * from #Something
    drop table #Something
    Desired output is:
    [Parent code] [Parent line Count] [Child line Count] [Child Line Migrations]
    P1c 1 3 3
    P1a 2 2  1
    P1b 1 2 1
    P1d 3 4  0
    The tricky part is in the migration table , if the parent line has got no migration, it will not appear in that table.
    Pls help guys
    thanks

  • Incorrect query forms in parent child relation

    Hello
    I am using jdev of RUP3 (Release 4) which is 11.1.1.6.2 and have following scenario
    I have a ParentVO (ProfileVO) and a child VO(CreditReceiversVO) (child VO is basically extended from another VO not in this application and included as a jar library).
    There a VL between ParentVO and ChildVO 1:* with two attributes ord_id and rule_id
    On UI these two VO instances are dropped as parent child and I get exception on running page in logs saying RuleAssignementEO.ORG_ID invalid identifier.
    Looking into the query formed by BC4J I see it as below which is clearly wrong as the alias RuleAssignmentEO is not visible for the outermost where clause. Please advise
    "SELECT count(1) FROM (SELECT * FROM (SELECT /*+ FIRST_ROWS(10) */
    RuleAssignmentsEO.RULE_ASSIGNMENT_ID,
    RuleAssignmentsEO.OBJECT_VERSION_NUMBER,
    RuleAssignmentsEO.RULE_ID,
    RuleAssignmentsEO.ASSIGNED_OBJECT_ID,
    RuleAssignmentsEO.ASSIGNED_OBJECT_TYPE,
    RuleAssignmentsEO.ORG_ID,
    RuleAssignmentsEO.ROLE_ID,
    RuleAssignmentsEO.START_DATE,
    RuleAssignmentsEO.END_DATE,
    RuleAssignmentsEO.SPLIT_PCT,
    RuleAssignmentsEO.REVENUE_TYPE,
    RuleAssignmentsEO.ROLLUP_FLAG,
    RuleAssignmentsEO.CREATED_BY,
    RuleAssignmentsEO.CREATION_DATE,
    RuleAssignmentsEO.LAST_UPDATED_BY,
    RuleAssignmentsEO.LAST_UPDATE_DATE,
    RuleAssignmentsEO.LAST_UPDATE_LOGIN,
    RuleAssignmentsEO.ATTRIBUTE_CATEGORY,
    RuleAssignmentsEO.ATTRIBUTE1,
    RuleAssignmentsEO.ATTRIBUTE2,
    RuleAssignmentsEO.ATTRIBUTE3,
    RuleAssignmentsEO.ATTRIBUTE4,
    RuleAssignmentsEO.ATTRIBUTE5,
    RuleAssignmentsEO.ATTRIBUTE6,
    RuleAssignmentsEO.ATTRIBUTE7,
    RuleAssignmentsEO.ATTRIBUTE8,
    RuleAssignmentsEO.ATTRIBUTE9,
    RuleAssignmentsEO.ATTRIBUTE10,
    RuleAssignmentsEO.ATTRIBUTE11,
    RuleAssignmentsEO.ATTRIBUTE12,
    RuleAssignmentsEO.ATTRIBUTE13,
    RuleAssignmentsEO.ATTRIBUTE14,
    RuleAssignmentsEO.ATTRIBUTE15,
    RuleAssignmentsEO.GROUP_MEMBER_CREDIT_FLAG,
    RuleAssignmentsEO.SUMMARY_FLAG,
    ParticipantEO.PARTICIPANT_NAME,
    ParticipantEO.PARTICIPANT_ID
    FROM CN_RS_RULE_ASSIGNMENTS_ALL RuleAssignmentsEO, CN_SRP_PARTICIPANT_HDR_RO_V ParticipantEO
    WHERE RuleAssignmentsEO.ASSIGNED_OBJECT_ID = ParticipantEO.PARTICIPANT_ID(+)) QRSLT WHERE RuleAssignmentsEO.RULE_ID = :Bind_RuleId AND RuleAssignmentsEO.ORG_ID = :Bind_OrgId) "
    Edited by: Vik2 on Oct 23, 2012 11:30 AM

    invalid identifier means ,it representating that field currently not available in db-table.
    so please refer db-table. whether field avialable or not?.
    edited lately:
    djbo.debugoutput=console did you use this :) it will say the query is send to server.
    Edited by: user707 on Oct 22, 2012 11:58 PM

  • Parent - child tables foreign key relation ship

    Hi All,
    we have 600 hundred tables ..i would like to print a hierarchial tree based on the foreigh key relathionship
    i tried my best but i couldnt.
    parent table
    child table 1
    childtable3
    child table 2
    and so
    Can somebody help me out with a query?
    Thanks,
    kt

    CREATE OR REPLACE FUNCTION get_child_tables (
    ptable VARCHAR2,
    powner VARCHAR2 DEFAULT 'SCOTT',
    plevel NUMBER DEFAULT 10
    RETURN stringarray
    -- -- create this ON SQL*PLUS "CREATE OR REPLACE TYPE STRINGARRAY AS TABLE OF VARCHAR2(50);"
    -- AUTHID CURRENT_USER
    PIPELINED
    AUTHOR DATE VERSION COMMENTS
    ======================================================================================
    [email protected] 26-OCT-2009 1.0 Developed to ease developers effort to find Nth level of Referential integrity
    ======================================================================================
    -- PURPOSE -> To find PARENT=> CHILD relational TABLE(S) in Oracle upto a depth max N Level.
    --SYNTAX TO USE
    SELECT * FROM TABLE( get_child_tables('DEPT','SCOTT',3)); Store this query in a file for your use
    SELECT * FROM TABLE( get_child_tables('EMPLOYEE')); Store this query in a file for your use
    -- RESULTS looks as below
    --1 => DEPT
    --2 => EMP
    --2 => EMP2
    --3 => EMP_CHILD
    --3 => EMP2_CHILD
    -- and so on
    --This can be leveraged to use in any oracle database REGION 10g having and above.
    --This FUNCTION gives formatted result of the Oracle 10g Hierarchical query result coded in the cursor
    --to find MASTER => CHILD relational TABLE(S) upto a depth max 10 Level.
    --The result of the PIPELINED function can be retrieved using Oracle new operator
    --TABLE(array name) in SQL query.
    --Due to the AUTHID CURRENT_USER compiler directive any user can use based on his/her access privileges on the database.
    --GRANT EXECUTE ON SCOTT.get_child_tables TO PUBLIC;
    --CREATE OR REPLACE PUBLIC SYNONYM get_child_tables FOR SCOTT.get_child_tables;
    IS
    atname stringarray := stringarray ();
    -- create this ON SQL*PLUS CREATE OR REPLACE TYPE STRINGARRAY AS TABLE OF VARCHAR2(50);
    vlevel NUMBER;
    vtname VARCHAR2 (50);
    nindex NUMBER := 0;
    bprocessed BOOLEAN := FALSE;
    CURSOR c1 (powner_in IN VARCHAR2, ptable_in VARCHAR2, plevel_in NUMBER)
    IS
    SELECT LEVEL, LPAD (' ', (LEVEL - 1) * 2, ' ') || pt AS "TNAME"
    FROM (SELECT a.owner w1, a.table_name pt, a.constraint_name c1,
    a.r_constraint_name r1, b.owner w2, b.table_name ct,
    b.constraint_name c2, b.r_constraint_name r2
    FROM all_constraints a, all_constraints b
    WHERE a.constraint_name = b.r_constraint_name(+)
    AND a.owner = b.owner(+)
    AND a.owner =
    UPPER (powner)
    -- Change Owner here while testing
    --AND A.r_constraint_name IS NULL
    AND a.constraint_type IN ('P', 'R')) v1
    START WITH pt =
    UPPER
    (ptable)
    -- Change your master table here while testing the QUERY
    CONNECT BY PRIOR ct = pt AND LEVEL <= plevel;
    -- Change lavel here while testing
    BEGIN
    atname.EXTEND;
    atname (1) := 'NOTHING';
    OPEN c1 (powner, ptable, plevel);
    LOOP
    bprocessed := FALSE;
    FETCH c1
    INTO vlevel, vtname;
    IF nindex > 1 AND atname (atname.LAST - 1) = vtname
    THEN
    --DBMS_OUTPUT.PUT_LINE('2 ==== vtname  ' ||vtname || '   '|| atname.count|| '   '||atname.last ||  '   '||atname( atname.last-1));
    bprocessed := TRUE;
    END IF;
    IF NOT bprocessed
    THEN
    nindex := nindex + 1;
    atname.EXTEND;
    atname (nindex) := vtname;
    PIPE ROW (vlevel || ' => ' || vtname);
    DBMS_OUTPUT.put_line ( ' **** nindex - atname( nindex) '
    || nindex
    || ' - '
    || atname (nindex)
    DLOG('ADDING ',vTname); A LOGGING ATONOMUS PROCEDURE FOR DEBUG PURPOSE
    END IF;
    EXIT WHEN c1%NOTFOUND;
    END LOOP;
    CLOSE c1;
    FOR i IN 1 .. atname.COUNT
    LOOP
    DBMS_OUTPUT.PUT_LINE('atname (i) ' ||atname (i));
    END LOOP;
    RETURN;
    EXCEPTION
    WHEN no_data_needed
    THEN -- THIS EXCEPTION HAS TO BE THERE TO GET THE FUCTION WORKABLE
    DBMS_OUTPUT.put_line (SQLERRM);
    RETURN;
    END get_child_tables;
    /

  • Script populate parent-child hierarchy not running

    Hallo guys
    I have problem when running script populate Parent-Child Relationship Table.
    Here is the script.I don't even change the script.just run it in PL/SQL
    declare
    v_max_depth integer;
    v_stmt varchar2(32000);
    i integer;
    begin
    select max(level) into v_max_depth
    from V_D_BRANCH
    connect by prior BRANCH_KEY=PARENT_BRANCH_KEY
    start with PARENT_BRANCH_KEY is null;
    v_stmt := 'insert into DM_ANALYTICS.BRANCH_HIERARCHY (MEMBER_KEY, ANCESTOR_KEY, DISTANCE, IS_LEAF)
                select BRANCH_KEY as member_key, null, null, 0 from V_D_BRANCH where PARENT_BRANCH_KEY is null
                union all
                select  member_key,
                replace(replace(ancestor_key,''\p'', ''|''), ''\'', ''\'') as ancestor_key,
                case when depth is null then 0
                else max(depth) over (partition by member_key) - depth + 1
                end as distance, is_leaf
    from
    select member_key,depth,
    case     when depth is null then '' || member_key
    when instr(hier_path, ''|'', 1, depth + 1) = 0 then null
       else substr(hier_path, instr(hier_path, ''|'', 1, depth) + 1, instr(hier_path, ''|'', 1, depth + 1) - instr(hier_path, ''|'', 1, depth) - 1)
    end ancestor_key,
    is_leaf
    from
        (    select BRANCH_KEY as member_key, PARENT_BRANCH_KEY as ancestor_key, sys_connect_by_path(replace(replace(BRANCH_KEY, ''\'', ''\''), ''|'', ''\p''), ''|'') as hier_path,
          case when BRANCH_KEY in (select PARENT_BRANCH_KEY from V_D_BRANCH ) then 0 else 1 end as IS_LEAF
    from V_D_BRANCH 
    connect by prior BRANCH_KEY = PARENT_BRANCH_KEY
    start with PARENT_BRANCH_KEY is null
      ( select null as depth from dual;
    for i in 1..v_max_depth - 1 loop
    v_stmt := v_stmt || union all select '' || i || '' from dual;
    end loop;
    v_stmt := v_stmt || ) )
    where ancestor_key is not null;
    execute immediate v_stmt;
    end;
    but I got errors like following:
    Error report -
    ORA-06550: line 19, column 12:
    PLS-00103: Encountered the symbol "insert into DM_ANALYTICS.BRANCH_HIERARCHY (MEMBER_KEY, ANCESTOR_" when expecting one of the following:
       ( - + case mod new not null <an identifier>
       <a double-quoted delimited-identifier> <a bind variable>
       continue avg count current exists max min prior sql stddev
       sum variance execute forall merge time timestamp interval
       date <a string literal with character set specification>
       <a number> <a single-quoted SQL string> pipe
       <an alternatively-quoted string
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    what should I do guys?any idea,any solution would be appreciated.thanks alot guys

    956850 wrote:
    hi,
    i tried making "Dimension with Parent-Child Hierarchy" as described in your tutorials.
    i finished with the admin tool and database changes and with no errors.
    when trying to create a new answer, by only puting the hierarchy column in the answer.
    the result show "no result" exist.
    i am not sure what i am doing wrong. maybe you can point me to the problem?
    thanks
    Mirit.Hi Mirit,
    What is the table that you created hierarchy on?
    Which column in the hierarchy you pulled into your reports to see the No Result message?
    Please query the table and see if has data.
    Thanks,
    G. SK

  • 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....

  • Parent child tables - how to maintain RI

    Here is my scenario:
    In our model, we have parent child relationship between tables.
    We are not sure how the parent tables are populated. If incremental update, it should be fine (assuming if needed rows will be inserted in the child table manually). If the tables are truncated and data is inserted again – that might be a problem since there exist relationship with child tables. What are the various options for handling such cases?
    Option1: cascade delete
    Option 2: ...?

    I'm not sure I understand the goal here...
    - Are you trying to design a data model? If so, wouldn't the business and data requirements tell you whether you need to truncate and reload the parent table or whether you can do an incremental load? It wouldn't seem to make sense to design a data model with no understanding of how the model is going to be used.
    - Are you trying to design a load process that works with an existing data model? If so, are you trying to design an incremental load? Or a load that involves a truncate and reload? Does the existing data model have foreign key constraints?
    Specifying the Oracle version and a bit of information about the application (i.e. is this an OLTP application, a data warehouse, something else) would probably also be helpful.
    Justin

  • OBIEE11g - Hierarchy parent-child with a factable measure(poor performance)

    Hi
    I have a star model with a hierarchy parent child, joined to the fact table.
    Creating a new analysis, and adding the hierarchy column with any other field from any dimension (on selected columns or filters) all works fine, and the hierarchy displays every level very fast.
    But adding a measure from the fact table, the hierarchy performance drops dramatically and I have to wait 20-30 seconds to see each new level displayed.
    Taking a look at the SQL launched, seems to be all right:
    The measure is a COUNT(DISTINCT factable.field) and the group by is done by Parent,Child fields in the hierarchy table.
    Is there any other way to set up this hierarchy? Why the measures are reducing the performance?
    Any comment will be helpful.
    Thanks in advance.

    Try these
    Use Oracle Enterprise Manager (EM) URL to monitor end to end OBIEE real time performance: http://<server>:7001/em
    In Oracle Business Intelligence 11g, the perfmon URL is still valid to use i.e. http://<server>:9704/analytics/saw.dll?Perfmon
    Check these
    http://www.rittmanmead.com/files/biforum2012/ranka_performance.pdf
    http://docs.oracle.com/cd/E17904_01/web.1111/e13814/jvm_tuning.htm
    https://blogs.oracle.com/pa/entry/obiee_ibm_jdk_tuning_for
    Support note OBIEE 11g Infrastructure Performance Tuning Guide Doc ID 1333049.1
    If helps mark and update back :)

  • Security on Employee Parent Child Dimension with SCD 2

    Hi
    I am looking for a solution for how to get all child members of a Parent employee including the one in the history. I tried multiple ways the problem which I am facing are
    Scenario 1: When I am using this approach, since the Employee with 'Jump' as employee id do have a history record with no children under him I am getting 'Null'. But there are new records (last 3 SCD changes) where he has employees under him.
    SELECT descendants(
    // Check if current employee is a manager
    iif(hierarchize(exists([Employee].[Manager Employee Dim ID].members,
    (strtomember("[Employee].[Employee Login ID].&[SIC\jump]"))),post).item(0).item(0).parent.datamember is
    hierarchize(exists([Employee].[Manager Employee Dim ID].members,
    (strtomember("[Employee].[Employee Login ID].&[SIC\jump]"))), post).item(0).item(0),
    // End of check if current employee is manager
    hierarchize(exists([Employee].[Manager Employee Dim ID].members,
    (strtomember("[Employee].[Employee Login ID].&[SIC\jump]"))),post).item(0).item(0).parent,
    hierarchize(exists([Employee].[Manager Employee Dim ID].members,
    (strtomember("[Employee].[Employee Login ID].&[SIC\jump]"))), post).item(0).item(0))) ON 0,
    [Measures].[Aggregate Count] On 1
    FROM [Data Ware House]
    Scenario 2: When I put a filter (as a set) to check if the record is current then I am getting the latest record for employee 'Jump'. But here the problem is that the employee under him I am only getting the [Measures].[Aggregate Count] of the latest
    change only.
    SELECT descendants(
    // Check if current employee is a manager
    iif(hierarchize(exists([UW Employee].[Manager Employee Dim ID].members,
    (strtomember("[UW Employee].[Employee Login ID].&[SIC\flew]"),[UW Employee].[Current Flag].&[Y])),
    post).item(0).item(0).parent.datamember is
    hierarchize(exists([UW Employee].[Manager Employee Dim ID].members,
    (strtomember("[UW Employee].[Employee Login ID].&[SIC\flew]"),[UW Employee].[Current Flag].&[Y])), post).item(0).item(0),
    // End of check if current employee is manager
    hierarchize(exists([UW Employee].[Manager Employee Dim ID].members,
    (strtomember("[UW Employee].[Employee Login ID].&[SIC\flew]"),[UW Employee].[Current Flag].&[Y])),
    post).item(0).item(0).parent,
    hierarchize(exists([UW Employee].[Manager Employee Dim ID].members,
    (strtomember("[UW Employee].[Employee Login ID].&[SIC\flew]"),[UW Employee].[Current Flag].&[Y])), post).item(0).item(0))
    ) ON 0,
    [Measures].[Contract Change Aggregate Count] ON 1
    FROM [Data Ware House]
    If any one can help me out with this that will be helpful.
    What I need is all the members under the employee 'Jump', including the Old scd records for 'jump'
    regards
    Robin
    Robs

    Hi,
    Outline is blank at the start of load and I expect dimensions Product and ProdAttribute to be added.
    Generations are unapplicable, since I can't turn this parent-child dimension (it's ragged) into generation one.
    And, by the way Integration Services manages to do this somehow, why rule files wouldn't?

  • Output as parent-child format

    Hi,
    I have this table REQ_DETAILS
    detail_id value_id parent
    282     125     281
    283     126     281
    284     119     (null)
    285     127     284
    286     128     284
    301     120     (null)
    341     1169     321
    303     130     301
    322     1168     321
    334     123     (null)
    335     129     301
    342     1170     321
    321     122     (null)
    361     1172     334
    362     1171     334
    363     119     (null)
    364     120     (null)
    365     1170     364
    281     118     (null)
    219     125     284
    The column PARENT refers to DETAIL_ID.
    and I've NUMTABLE of type INTEGER. (create or replace TYPE NUMTABLE AS TABLE OF INTEGER;)
    I'd like to write a function which takes detail_id's as input and returns the correct order of the input. (parent-child format)
    for example
    order_req_det (detId_in NUMTABLE) return NUMTABLE;
    order_req_det (219, 284, 285, 286, 282, 283, 281, 362, 334, 361)
    should return the below output.
    284
    219
    285
    286
    281
    282
    283
    334
    361
    362
    Any suggestions?
    Regards.

    Guys, not even a suggestion?
    SQL> desc numtable;
    numtable TABLE OF NUMBER(38)
    SQL> select * from test;
    DETAIL_ID   VALUE_ID     PARENT
           282        125        281
           283        126        281
           284        119
           285        127        284
           286        128        284
           301        120
           341       1169        321
           303        130        301
           322       1168        321
           334        123
           335        129        301
           342       1170        321
           321        122
           361       1172        334
           362       1171        334
           363        119
           364        120
           365       1170        364
           281        118
           219        125        284
    20 rows selected.
    SQL> declare
      2   vt1 numtable :=
      3        numtable(219, 284, 285, 286, 282, 283, 281, 362, 334, 361);
      4   vt2 numtable;
      5   vt3 numtable;
      6   vt4 numtable := numtable();
      7   --v2 number;
      8  begin
      9   select detail_id
    10   bulk collect into vt2
    11   from test
    12   where parent is null
    13   and detail_id in( select column_value
    14                     from table(vt1));
    15   for i in 1..vt2.count loop
    16    select detail_id
    17    bulk collect into vt3
    18    from test
    19    start with detail_id = vt2(i)
    20    connect by prior detail_id = parent
    21    order siblings by detail_id;
    22    vt4 := vt4 multiset union vt3;
    23   end loop;
    24   for i in 1..vt4.count loop
    25    dbms_output.put_line(vt4(i));
    26   end loop;
    27  end;
    28  /
    284
    219
    285
    286
    281
    282
    283
    334
    361
    362
    PL/SQL procedure successfully completed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Event logging in Parent-Child packages

    Hello,
    I have a set of Parent-Child SSIS packages. A Parent package invokes a bunch of child packages via "Execute Package Tasks".
    I have set up custom event logging (to a SQL table) inside both Parent and Child Packages' Event Handlers (OnPreExecute, OnPostExecute, OnError).
    I noticed that when a Child Package raises an event, both the Child Package's event handler and the Parent Package's event handler get fired, thereby creating duplicate event logging entries.
    So, as a quick work around, I disabled event handlers in Child packages hoping that the Parent Package's event handlers will catch and log all events nicely. However, when the Parent Package's event handler writes event details to the table, it uses the
    Parent Package's System::PackageId, System::PackageGUID and System::PackageName rather than that of the Child Package that originally raised the event!. So, my event log table records all events as if they were raised by the Parent Package!
    Is it possible to disbale event bubbling up from Child Packages to the Parent package?
    What options do I have to fix this problem?
    Thanks

    I came across this same issue and found a pretty nice workaround.
    In brief, I used a Stored Procedure to write the OnError to a Logging table. So when this stored procedure was called I checked if the error was already in the logging table, and if it was then no record would be inserted.
    I was already using the logging method 2 detailed here with a few changes.
    To the PackageLog table I added a ParemtExecutionID value, which was passed into the child package through a Parent Variable Configuration. So for the OnPreExecute handler, the Parent Package passed NULL for the ParemtExecutionID, but the Child Package passed
    in the Variable.
    In the ErrorLog table I added a SourceID column, which is the GUID of the task that generated the error. In the Parent/Child Package configuration, the SourceID is the same in both OnError handlers.
    So then when the Parent OnError handler calls the stored procedure, it checks if an ErrorLog record exists for the ParentExecutionID and SourceID combination.
    Below is the OnError Stored Procedure I used. (Note: In my example only the Child Package has a Queue ID value.)
    Create Procedure [dbo].[usp_Integration_Log_Error] (
    @Execution_Id UNIQUEIDENTIFIER,
    @Queue_Id INTEGER = NULL,
    @Source_Name VARCHAR(255),
    @Source_Id UNIQUEIDENTIFIER,
    @Err_Code INTEGER,
    @Err_Message NVARCHAR(MAX)
    AS
    BEGIN
    DECLARE @ErrorCount INTEGER
    IF @Queue_Id IS NULL
    SELECT
    @ErrorCount = Count(*)
    FROM
    INTEGRATION_ERROR IE
    INNER JOIN
    INTEGRATION_LOG IL ON IE.EXECUTION_ID = IL.EXECUTION_ID
    WHERE
    IL.PARENT_EXECUTION_ID = @Execution_Id AND
    IE.SOURCE_ID = @Source_Id
    IF ISNULL(@ErrorCount,0) = 0
    INSERT INTO
    INTEGRATION_ERROR (
    EXECUTION_ID,
    QUEUE_ID,
    SOURCE_NAME,
    SOURCE_ID,
    ERR_CODE,
    ERR_MESSAGE
    VALUES (
    @Execution_Id,
    @Queue_Id,
    @Source_Name,
    @Source_Id,
    @Err_Code,
    @Err_Message
    END

  • Options for loading parent-child SQL 2005 tables

    I was reading about a few examples of using Table types and a stored procedure to load tables that are joined by a foreign key (parent-child).  Seems straight forward enough.  However, that requires at least SQL 2008 and the system we are using
    is on 2005 still for the time being. As much as I would like to upgrade, there is no time for it, even though we have other 2008 and 2012 instances.  So with that said, what are my options for getting data from BTS to SQL where the destination is 2 tables
    that have relations.  
    There are probably a dozen or more, but my first thought is a stored procedure with an xml parameter, then use xquery and xpath statements to pull the data out and insert.  TRY/CATCH and RAISEERROR to return error codes back to the BTS application.
    Thoughts?

    First, how many records are you dealing with?  I don't even think of terms of 'bulk' until 10,000 or so.  And once that threshold is crossed, the first tool out of the box is SSIS.
    Second, are you debatching or is there a triple confirmed requirement that all records be loaded in a single transaction?
    Finally, the 'DB round-trip' issue is often misunderstood in real world settings.  In a typical db transaction, the most expensive operation is establishing the connection.  Once that's done, the SQL Client is very efficient in transporting data
    to and from the database.  Since the wcfSqlBinding uses a Connection Pool, that setup is only done once to some high-water mark.
    Consider, the data has to be sent no matter what and in every conseivable scneario*, the byte count of a stored procedure over TDS would be less than sending the same data wrapped in Xml.  The network adds considerable latency to the conversation. 
    This is why I'm skeptical of using OPENXML() without a provable benefit.
    So, don't get caught up in theoritical 'performance' issues without understanding the entire scenario first.
    *SQL Code being the primary exception.

  • Merge data/result sets that are't parent/child?

    Hi:
    I've seen a few examples of making a data template so that a BI report can have master/detail data. They make a Q1 data set and a Q2 data set with a bind variable to link the two in a parent/child relationship.
    But what I need is effectively a UNION. I have the same table on multiple database instances and I want to show the grouped results in one report as if it all came from one table. The master/detail examples have a section defining grouping but they group by Q1 (see here)
    http://blogs.oracle.com/BIDeveloper/data_template/
    and I need to group by a column that is in Q1 and Q2 to "merge" the two data sets.
    Has anyone done this?
    Thanks.

    I've messed up what I had! lol
    I'll try and recreate things tomorrow and get it to you, thanks.
    I seem to be having some quirks with all this (or I'm just confused). I initially had a data model that selected a few columns and a count(*) an grouped the results. I modified the data model to not have the count but every time I do "insert table/chart" in RTF the count column shows up as a possible column to move over with >>. I've re-opened the document so it should have the latest data model. Is this normal? A bug? Am I just lost?
    Thanks.

  • Dynamic Security in a denormalized Parent-Child dimension Table

    Hi guys, I need your priceless help again:
    I have a parent child relationship in a table with a fixed depth, let´s say Region-->Area-->Country
    I denormalized the table to have something like this
    Then, to implement dynamic security, I think in a bridge table with the userId
    and the CountryId, then with a measure group and a measure which count the combination of user/country I can proof the security using the non empty function.
    My question is how can I also set security for the levels above the leaf members, let´s say, I want to assign an user to the Area level or Region Level. I don't know exactly which key could I include in the bridge table.
    I may want to keep the id´s of the original table in the different levels.
    Any comment will be appreciated.
    Kind Regards,

    Hi Paul,
    According to your description, you want to apply dynamic security on parent-child hierarchy. Right?
    In Analysis Services, when a dimension contains a parent-child hierarchy, we can't set up security directly on the key attribute. Because it will not appear on the dropdown list of Dimension Data Security in Role editor.
    In this scenario, we need to filter on key attribute and not the parent-child hierarchy. Then use Linkmember() to find the equivalent members on the parent-child hierarchy. Please refer to the expression below based on a employee dimension with parent-child
    hierarchy.
    Generate(
     NonEmpty(
      [Employee].[Employee].[Employee].Members,
       [Measures].[Employee Count],
       StrToMember('[User].[User].[' + UserName() + ']')
                 LinkMember(
                     [Employee].[Employee].CurrentMember,
                     [Employee].[Employees]
    Also I suggest an excellent book:
    Expert Cube Development with Microsoft SQL Server 2008 Analysis Services. It talks about this scenario in chap 9.
    Reference:
    SSAS
    Dynamic security - Bridge table (factless) between User dimension and Parent-Child (PC) dimension
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou
    TechNet Community Support

  • Query Help with Parent, Child, Child's Child

    Hi all,
    Need some help with a query.  I'm trying to create a stored procedure that is sort of like a Customer, Order, Order, Details.  In my situation the tables are different but nevertheless, I want to grab all the fields from the  Parent, Child,
    and Childs' Child, where the Parent.ParentID = @Parameter.  I tried this:
    CREATE PROCEDURE [dbo].[spGetCompleteProjectXML]
    @ProjectID int = 0
    AS
    SELECT *,
    (SELECT *,
    (SELECT *
    FROM PageControls
    WHERE (PageControls.ProjectPageID = ProjectPages.ProjectPageID))
    FROM ProjectPages
    WHERE (ProjectPages.ProjectID = @ProjectID))
    FROM Projects
    WHERE (ProjectID = @ProjectID)
    FOR XML AUTO, ELEMENTS
    RETURN 0
    I think I'm close, but it was my best effort.  Could someone help?
    thanks in advance

    Hi TPolo,
    Regarding your description, are you looking for a sample like below?
    CREATE TABLE customer(customerID INT, name VARCHAR(99))
    INSERT INTO customer VALUES(1,'Eric')
    INSERT INTO customer VALUES(2,'Nelson')
    CREATE TABLE orders(orderID INT,customerID INT)
    INSERT INTO orders VALUES(1,1);
    INSERT INTO orders VALUES(2,1)
    INSERT INTO orders VALUES(3,2)
    INSERT INTO orders VALUES(4,2)
    CREATE TABLE orderDetails(orderID INT,item VARCHAR(99))
    INSERT INTO orderDetails VALUES(1,'APPLE1')
    INSERT INTO orderDetails VALUES(1,'BANANA1')
    INSERT INTO orderDetails VALUES(2,'APPLE2')
    INSERT INTO orderDetails VALUES(2,'BANANA2')
    INSERT INTO orderDetails VALUES(3,'APPLE3')
    INSERT INTO orderDetails VALUES(3,'BANANA3')
    INSERT INTO orderDetails VALUES(4,'APPLE4')
    INSERT INTO orderDetails VALUES(4,'BANANA5')
    SELECT customer.customerID,customer.name,
    (SELECT orderId,
    SELECT item FROM orderDetails WHERE orderID=orders.orderID FOR XML AUTO,TYPE,ELEMENTS
    FROM orders Where customerID=customer.customerID FOR XML AUTO,TYPE,ELEMENTS)
    FROM customer WHERE customerID=1
    FOR XML AUTO,ELEMENTS
    DROP TABLE customer,orderDetails,orders
    If you have any feedback on our support, please click
    here.
    Eric Zhang
    TechNet Community Support

Maybe you are looking for

  • Problem in currency decimal format

    Hi all, we want to display currency format 1,234,567.89 but we are getting current format as 1.234.567,89 we already maintained the required format in the USER PROFILE's DEFAULT still we are getting this format 1.234.567,89 so is there any thing we h

  • Billing plan and billing status

    Hello Friends, I would like to clarify if my understanding is correct before I configure a billing plan: 1. Billing status is not seen in billing doc but in preceding doc like a DO. 2. For a Billing Plan, there can be 1 billing plan at item level for

  • Sync self made slide shows from with titles and music to I TOUCH

    Trying to sync pictures i have put into slide show with titles and music to I touch is there away

  • IMovie '11 preview/play issues?

    I just bought iMovie '11 for my MacBook (using OS X Lion (10.7.1)), and I am having this weird issue during playback. I have placed PNG images (transparent backgrounds) on top of the main background scenes using the 'cutaway' option. When I do a test

  • Ipods and windows

    Ok. I have a Video Ipod and I updated it on a windows computer. Say if I wanted to go on to a different windows computer and get the music and videos off that computer, Will it allow me to or will i have to restore my computer?   Mac OS X (10.4.2)