Hirarchial query

Hi
I use Oracle 9.2.0.1 Database
I try to bulid a temporary table which will be loaded by data from a procedure. The data should be gathered from two other tables:
1 - hirarchial table of items
2 - financial data that exist in the a different table that uses the lowest items in the hirarchial table (mentioned in item 1)
Table 1 structure name=fin_structure:
structure_id number(5)
catalog_id number(5)
master_item_id varchar2(15)
detailed_item_id varchar2(15)
Table 2 structure name=fin_data:
structure_id number(5)
catalog_id number(5)
org_unit_id varchar2(15)
item_id varchar2(15)
sum_1 number
sum_2 number
sum_3 number
sum_4 number
Eample of data:
fin_structure
4 3 0 1
4 3 1 35
4 3 35 35000
4 3 35 35010
4 3 0 3
4 3 3 50
4 3 50 50000
4 3 3 51
4 3 51 51000
4 3 51 51200
fin_data
4 3 15010 35000 -3000000 -15000 0 0
4 3 15010 50000 -56886.25 -25000 0 1
4 3 15010 51000 61600 32000 0 0
4 3 15010 51200 10800 0 1 1
4 3 20010 35000 -2000000 -10000 0 0
4 3 20010 50000 1 1 0 1
4 3 20010 51000 1 1 0 0
4 3 20010 51200 1 1 1 1
I want for each org_unit_it to aggregate all item_id according to the hirarchial structure. Once I've asked about this issue, and I've got a solution. It worked fine, but with a lot of data it takes lots of time, (and I had to duplicate several of the query for each sum column).
Here is a link to previous reply:
{thread:id=2351632}
The output shold look like that:
Structure:
org_unit_id
master_item_id
detailed_item_id ( in leaf levels = item_id in fin_data)
sum_1
sum_2
sum_3
sum_4
Data:
15010 35 35000 -3000000 -15000 0 0
15010 35 -3000000 -15000 0 0
15010 1 -3000000 -15000 0 0
15010 50 50000 -56886.25 -25000 0 1
15010 50 -56886.25 -25000 0 1
15010 51 51000 61600 32000 0 0
15010 51 51200 10800 0 1 1
15010 51 72400 32000 1 0
15010 3 15513.75 7000 1 1
15010 -2984486.25 8000 1 1
20010 35 35000 -2000000 -10000 0 0
20010 35 -2000000 -10000 0 0
20010 1 -2000000 -10000 0 0
20010 50 50000 1 1 0 1
20010 50 1 1 0 1
20010 51 51000 1 1 0 0
20010 51 51200 1 1 1 1
20010 51 2 2 1 1
20010 3 3 3 1 2
20010 -1999997 -9997 1 2
Here is the code I've used (its a part from a package, so there are functions and procedures that i call and not in this post. These are not the problems. sum1 ... sum4 has different names in the procedure, and there are some more of them. these are examples):
cursor c1 is
      select max(level) --, max(rownum)
        from fin_structure
       where structure_id = inStructureId
       start with master_item_id = 'TOTAL'
      connect by prior detailed_item_id = master_item_id;
    cursor c2 is
      select distinct organisation_unit_id,
                      get_org_unit_desc(organisation_unit_id, catalog_id) org_unit_desc
        from fin_data
       where structure_id = inStructureId
         and organisation_unit_id between inFromOrgUnitId and inToOrgUnitId
       order by organisation_unit_id;
    cursor c3 is
      with t_main as
       (select bis.structure_id,
               bis.catalog_id,
               bis.master_item_id,
               bis.detailed_item_id,
               sys_connect_by_path(bis.detailed_item_id, ',') || ',' path,
               bbv.org_unit_desc,
               bbv.item_desc,
               bbv.sum_planned,
               bbv.sum_add,
               bbv.sum_freeze,
               bbv.total_budget_nf,
               bbv.total_budget_wf,
               bbv.sum_reserved,
               bbv.sum_actual,
               bbv.balance_nf,
               bbv.balance_wf
          from fin_structure bis,
               (select *
                  from fin_data
                 where structure_id = inStructureId
                   and organisation_unit_id = vDetailedOrgUnitId
                   and item_id between inFromItemId and inToItemId
                   and budget_year = inYear) bbv
         where bbv.structure_id(+) = bis.structure_id
           and bbv.catalog_id(+) = bis.catalog_id
           and bbv.item_id(+) = bis.detailed_item_id
         start with bis.master_item_id = 'TOTAL'
        connect by bis.master_item_id = prior bis.detailed_item_id),
      t_planned as
       (select path,
               length(path || chr(1)) -
               length(translate(path || chr(1), chr(0) || ',', chr(0))) - 1 lvl,
               master_item_id,
               get_item_desc(master_item_id, catalog_id) master_item_desc,
               detailed_item_id,
               get_item_desc(detailed_item_id, catalog_id) detailed_item_desc,
               (select sum(sum_planned)
                  from t_main b
                 where b.structure_id = a.structure_id
                   and b.catalog_id = a.catalog_id
                   and b.path like a.path || '%'
                   and (length(path || chr(1)) -
                       length(translate(path || chr(1),
                                         chr(0) || ',',
                                         chr(0))) - 1) <= inToLevel) sum_planned
          from t_main a),
      t_add as
       (select master_item_id,
               detailed_item_id,
               (select sum(sum_add)
                  from t_main b
                 where b.structure_id = a.structure_id
                   and b.catalog_id = a.catalog_id
                   and b.path like a.path || '%') sum_add
          from t_main a),
      t_freeze as
       (select master_item_id,
               detailed_item_id,
               (select sum(sum_freeze)
                  from t_main b
                 where b.structure_id = a.structure_id
                   and b.catalog_id = a.catalog_id
                   and b.path like a.path || '%') sum_freeze
          from t_main a),
      t_total_budget_nf as
       (select master_item_id,
               detailed_item_id,
               (select sum(total_budget_nf)
                  from t_main b
                 where b.structure_id = a.structure_id
                   and b.catalog_id = a.catalog_id
                   and b.path like a.path || '%') total_budget_nf
          from t_main a),
      t_total_budget_wf as
       (select master_item_id,
               detailed_item_id,
               (select sum(total_budget_wf)
                  from t_main b
                 where b.structure_id = a.structure_id
                   and b.catalog_id = a.catalog_id
                   and b.path like a.path || '%') total_budget_wf
          from t_main a),
      t_reserved as
       (select master_item_id,
               detailed_item_id,
               (select sum(sum_reserved)
                  from t_main b
                 where b.structure_id = a.structure_id
                   and b.catalog_id = a.catalog_id
                   and b.path like a.path || '%') sum_reserved
          from t_main a),
      t_actual as
       (select master_item_id,
               detailed_item_id,
               (select sum(sum_actual)
                  from t_main b
                 where b.structure_id = a.structure_id
                   and b.catalog_id = a.catalog_id
                   and b.path like a.path || '%') sum_actual
          from t_main a),
      t_balance_nf as
       (select master_item_id,
               detailed_item_id,
               (select sum(balance_nf)
                  from t_main b
                 where b.structure_id = a.structure_id
                   and b.catalog_id = a.catalog_id
                   and b.path like a.path || '%') balance_nf
          from t_main a),
      t_balance_wf as
       (select master_item_id,
               detailed_item_id,
               (select sum(balance_wf)
                  from t_main b
                 where b.structure_id = a.structure_id
                   and b.catalog_id = a.catalog_id
                   and b.path like a.path || '%') balance_wf
          from t_main a)
      select path,
             lvl,
             tp.master_item_id,
             tp.master_item_desc,
             lpad(' ', lvl) || tp.detailed_item_id tree_detailed_item_id,
             tp.detailed_item_id,
             tp.detailed_item_desc,
             sum_planned,
             sum_add,
             sum_freeze,
             total_budget_nf,
             total_budget_wf,
             sum_reserved,
             sum_actual,
             balance_nf,
             balance_wf
        from t_planned         tp,
             t_add             tad,
             t_freeze          tf,
             t_total_budget_nf ttbnf,
             t_total_budget_wf ttbwf,
             t_reserved        tr,
             t_actual          tac,
             t_balance_nf      tbnf,
             t_balance_wf      tbwf
       where (sum_planned is not null or sum_add is not null or
             sum_freeze is not null or total_budget_nf is not null or
             total_budget_wf is not null or sum_reserved is not null or
             sum_actual is not null or balance_nf is not null or
             balance_wf is not null)
         and tp.master_item_id = tad.master_item_id
         and tp.master_item_id = tf.master_item_id
         and tp.master_item_id = ttbnf.master_item_id
         and tp.master_item_id = ttbwf.master_item_id
         and tp.master_item_id = tad.master_item_id
         and tp.master_item_id = tr.master_item_id
         and tp.master_item_id = tac.master_item_id
         and tp.master_item_id = tbnf.master_item_id
         and tp.master_item_id = tbwf.master_item_id
         and tp.detailed_item_id = tad.detailed_item_id
         and tp.detailed_item_id = tf.detailed_item_id
         and tp.detailed_item_id = ttbnf.detailed_item_id
         and tp.detailed_item_id = ttbwf.detailed_item_id
         and tp.detailed_item_id = tr.detailed_item_id
         and tp.detailed_item_id = tac.detailed_item_id
         and tp.detailed_item_id = tbnf.detailed_item_id
         and tp.detailed_item_id = tbwf.detailed_item_id
      union all
      select null,
             null,
             null,
             null,
             null,
             null,
             null,
             sum(sum_planned),
             sum(sum_add),
             sum(sum_freeze),
             sum(total_budget_nf),
             sum(total_budget_wf),
             sum(sum_reserved),
             sum(sum_actual),
             sum(balance_nf),
             sum(balance_wf)
        from t_main
       order by lvl, master_item_id, detailed_item_id;
            begin
              select structure_sort
                into vC4_RowNum
                from fin_structure
               where structure_id = inStructureId
                 and detailed_item_id = vDetailedItemId
                 and master_item_id = vMasterItemId;
            exception
              when no_data_found then
                vC4_RowNum := '';
            end;
            if nTreeLevel < nMaxLevel then
              vMasterOrgUnitId := 'B';
            else
              vMasterOrgUnitId := '';
            end if;
            vMasterOrgUnitDesc := vC4_RowNum;
            insert_budget_tree_gtmp(inStructureId,
                                    nTreeLevel,
                                    vPath,
                                    inYear,
                                    vMasterOrgUnitId,
                                    vMasterOrgUnitDesc,
                                    vDetailedOrgUnitId,
                                    vDetailedOrgUnitDesc,
                                    vMasterItemId,
                                    vMasterItemDesc,
                                    vTreeDetailedItemId,
                                    vDetailedItemId,
                                    vDetailedItemDesc,
                                    nSumPlanned,
                                    nSumAdd,
                                    nSumFreeze,
                                    nTotalBudgetNF,
                                    nTotalBudgetWF,
                                    nSumReserved,
                                    nSumActual,
                                    nBalanceNF,
                                    nBalanceWF);
          end if;
        end loop;
      end loop;Thanks for help
Edited by: user400097 on Apr 13, 2012 9:42 AM

Ok, that's a lot for us to trawl through and not something we can put on our own test database and replicate.
What you're essentially saying is that your process runs slowly when you have a lot of data.
Looking at your code, it's not clear exactly what you're doing because you've obviously left out some of the code.
What is clear though is that you appear to be doing nested cursor loops...
        end loop;
      end loop;and inserting individual records inside those loops.
This is known as row-by-row processing, or more affectionatly known as slow-by-slow processing because it's one of the slowest ways of processing data.
Essentually what you are trying to achieve is the insertion of a lot of records based on some queries. The most performant way of doing that would be to try and combine everything into a single SQL statement that juts does an INSERT .... SELECT .... and leaves out the PL/SQL loops completely. The reason... every time you use a pl/sql cursor loop with SQL statements inside it, you are causing a context switch between the PL/SQL engine and the SQL engine. It takes time to do that switch; to pass across the information from one engine to the other. With a single SQL statement on the other hand it would just be a single context switch, so the actual processing would be performed by the SQL engine at it's optimum speed.

Similar Messages

  • Forms Trigger Hirarchy for Execute query operation

    Hi
    Can anybody tell me in which order triggers are executed in oracle forms
    when i press a execute query button.
    ON-POPULATE-DETAILS
    ON-CHECK-DELETE-MASTER
    POST-QUERY
    i want to write a code after completion of all the operations of execute_query
    requirement is after excute_query i want to append few more record in multiline detail block of master-detail relation.
    where should i write this code.
    regds

    POST-TEXT-ITEM
    POST-RECORD
    PRE-QUERY
    PRE-SELECT
    POST-SELECT
    POST-QUERY( x times )
    ON-CLOSE
    PRE-RECORD
    PRE-TEXT-ITEM
    WHEN-NEW-RECORD-INSTANCE
    WHEN-NEW-ITEM-INSTANCE
    Francois

  • Display the foreign keys and primary keys in hirarchy qeury  please ?

    Any sql query to get the following columns:
    I should display all the master table names,it's primary key field and its foregin key field,the name of the foreignkey'table.
    This should be displayed in hirarchy i.e. it should start from the top level table like upside down tree.
    can we query the database like this
    thanx in advance
    prasanth a.s.

    hi there,
    Please can any body help in this query!
    Thanxs in advance
    prasanth a.s.

  • Fixing row characteristics in sap bi report using query designer

    Hello ,
    I have requirement as follows :
    In my sap bi report there are row characteristics in sequence as follows :
    1) zone 2) project description 3) wbs hirarchy 4) wbs description 
    and  free characteristics as
    1) name of vendor
    2) network description .
    3) network
    Requirement is : I nee to freeze the first 3 row characteristics means no one can drag and drop free characteristics in between these ( i mean he can't drop free characteristics between zone and project description ) . Also , he can't drag an drop any of these to free characteristics .
    He can drag and drop after these rows characteristics .
    Any idea how it can be implemented in query designer

    Its still same.
    http://help.sap.com/saphelp_nw04s/helpdata/en/4d/e2bebb41da1d42917100471b364efa/content.htm

  • Query to get direct report and anyone under them.

    Hello
    Does anyone have a query that would give me a supervisor and his/her direct reports and any direct reports of someone that reports to that supervisor?
    For an example if Kim reports to Jon and Jon reports to Doug and Doug reports to Steve.
    Example
    Steve's direct reports, would be Jon, Doug and Kim
    Jon's direct report, would be Kim.
    Any Idea's
    Thanks,
    KRE

    Please check previous threads -
    Re: How to find loop in Supervisor Hirarchy.
    Supervisor Hierarchy
    Re: Query for Supervisor Hierarchy for top most manager
    Cheers,
    VB

  • Problem when querying OLAP for Value based hierarchy

    Hi I have problem when querying OLAP for value based hierarchy , for level based dimension it work fine
    the strange part is if I only put one value, it will work perfectly
    for example if I put only 1 value for that value base hierarchy like CF_HIER::426362, then it will get the correct value for that id 426362
    but if I put multiple value to the list
    CF_HIER::426362
    CF_HIER::424470
    CF_HIER::429073
    CF_HIER::424230
    then only some value will come out correctly, some of them will be 0, I wonder why because if I query using each value, then it show correct value
    for multiple value usually only the top in hirarchy give correct value, but the leaf will give 0, but if I query only the leaf, the leaf will give correct value
    this problem only happen for my value based hierarchy, for the level based hierarchy it work fine both for each value or multiple value in the list
    this is the code how I guery
    ////the "elementIdList" is where the value is (CF_HIER::426362,CF_HIER::424470,CF_HIER::429073,CF_HIER::424230), if I only put single value in this list the query work fine, but if I put multiple value then some value give correct result, some will give 0
    String[] elementIdArr = new String[elementIdList.size()];
              int i = 0;
              for (Long elementId: elementIdList) {
                   String elementIdStr ="";
                   if (hierarchy instanceof MdmLevelHierarchy)
                        elementIdStr = hierarchy.getName()+dimension.getValueSeparationString()+
                                            level.getName()+dimension.getValueSeparationString()+
                                            level.getName()+"_"+elementId;
                   else
                        elementIdStr = hierarchy.getName()+dimension.getValueSeparationString()+
                                            elementId;
                   elementIdArr[i++] = elementIdStr;
              Source myList = dp.createListSource(elementIdArr);
              result = hierarchy.getSource().selectValues(myList);
         Source joinedSource = measure.getSource();
              joinedSource = joinedSource.join(result );
    is there any suggestion where I'm doing wrong?or is it different between querying value based hier with level based hier?
    thanks

    Hi I have problem when querying OLAP for value based hierarchy , for level based dimension it work fine
    the strange part is if I only put one value, it will work perfectly
    for example if I put only 1 value for that value base hierarchy like CF_HIER::426362, then it will get the correct value for that id 426362
    but if I put multiple value to the list
    CF_HIER::426362
    CF_HIER::424470
    CF_HIER::429073
    CF_HIER::424230
    then only some value will come out correctly, some of them will be 0, I wonder why because if I query using each value, then it show correct value
    for multiple value usually only the top in hirarchy give correct value, but the leaf will give 0, but if I query only the leaf, the leaf will give correct value
    this problem only happen for my value based hierarchy, for the level based hierarchy it work fine both for each value or multiple value in the list
    this is the code how I guery
    ////the "elementIdList" is where the value is (CF_HIER::426362,CF_HIER::424470,CF_HIER::429073,CF_HIER::424230), if I only put single value in this list the query work fine, but if I put multiple value then some value give correct result, some will give 0
    String[] elementIdArr = new String[elementIdList.size()];
              int i = 0;
              for (Long elementId: elementIdList) {
                   String elementIdStr ="";
                   if (hierarchy instanceof MdmLevelHierarchy)
                        elementIdStr = hierarchy.getName()+dimension.getValueSeparationString()+
                                            level.getName()+dimension.getValueSeparationString()+
                                            level.getName()+"_"+elementId;
                   else
                        elementIdStr = hierarchy.getName()+dimension.getValueSeparationString()+
                                            elementId;
                   elementIdArr[i++] = elementIdStr;
              Source myList = dp.createListSource(elementIdArr);
              result = hierarchy.getSource().selectValues(myList);
         Source joinedSource = measure.getSource();
              joinedSource = joinedSource.join(result );
    is there any suggestion where I'm doing wrong?or is it different between querying value based hier with level based hier?
    thanks

  • Using conditional formating on member columns in essbase hirarchy in obiee

    Hi All,
    I ws analysing an existing sample PnL report in obiee 11g.
    Wht I found that there is conditional formating used on 'Balance' member column based on one of the member column (net income) from 'income statement' hirarchy of essbase cube. I tried to open the 'Conditional Format' tab and tried to look into the conditional formating based on the columns above. Wht I noticed that , in the filter, some values are uses such as equal to is in 300000 and so on.. I thought of editing the value to specify another value, but could not edit the value as it is non editable.
    Can anyone tell me how to specify such value.? I tried to furhter investigate and found that is is actually comming from net income member, but I am not able to edit it modify it.. I wanted to used this formatting feature in my another report which I created from scratch, but not able to understand how to do it..
    Any help, please?
    Thanks and Regards
    Santosh

    Hi Dhar,
    Thank you for your quick reply.
    I have added couple of screenshot to flickr to clarify my problem: http://www.flickr.com/photos/93812026@N07/
    Picture 1:
    Yes, your assumption is correct. We are using gen x level members in report, but these members are shared members or Dynamic calculations i.e. we have created custom account hierarchy for them.
    Picture 2:
    Basic situation, when I query that hierarchy. I.e. it returns account names for both members in the hierarchy. Furthermore, so far I have used only one pair of account, i.e. WOC
    Picture 3:
    I'm able to "merge" these two account members simply by adding "case when" statement to account dimension object. It shows values correctly in a table (picture 4)
    Picture 5:
    BUT, when adding other accounts to query filter, the returned values are no longer correct, but some sort of multiplication.
    --> it seems, that OBIEE cannot figure the context it should do the calculation against and I don't know how to define it there.
    Ps. Next step was, that we tried to use dashboard prompt to return correct values to calculations, but after being able calculate correctly values for these above mentioned accounts, we ran into problem, when trying to add entity level to dashboard prompt (OBIEE gave an error refering Essbase). I believe this is a bug in this version.
    -Esa-

  • How to find loop in Supervisor Hirarchy.

    How to find loop in Supervisor Hirarchy.
    Employee - > supervisor 1 (Manager) ->supervisor 2 (Manager) -> Employee (Manager)
    Thanks

    Remember to always truncate the time portion when checking effective dates in HRMS. So the query should be rewritten as:
    SELECT
    a.business_group_id, a."PERSON_ID",a.assignment_id, a."EMPLOYEE_NUMBER", a."FULL_NAME",
    a."SUPERVISOR_ID", a."SUPERVISOR_EMP_NO", a."SUPERVISOR",
    a."ORGANIZATION_ID",a."POSITION",
    LEVEL level1,
    CONNECT_BY_ROOT supervisor_emp_no top_supervisor,
    CONNECT_BY_ISCYCLE loopback,
    CONNECT_BY_ROOT supervisor_id as top_supervisor_id,
    SYS_CONNECT_BY_PATH (supervisor_emp_no, '/') PATH
    FROM (SELECT
    papf.business_group_id,
    papf.person_id,
    paaf.assignment_id,
    papf.employee_number,
    papf.full_name,
    paaf.supervisor_id,
    papf1.employee_number supervisor_emp_no,
    papf1.full_name supervisor,
    paaf.organization_id,
    hr_general.DECODE_POSITION(paaf.position_id) position
    FROM per_all_people_f papf,
    per_all_assignments_f paaf,
    per_all_people_f papf1
    WHERE papf.person_id = paaf.person_id
    AND papf1.person_id = paaf.supervisor_id
    and papf.CURRENT_EMPLOYEE_FLAG = 'Y'
    AND paaf.primary_flag = 'Y'
    AND papf.business_group_id = paaf.business_group_id
    AND papf1.business_group_id = papf.business_group_id
    AND TRUNC(SYSDATE) BETWEEN papf.effective_start_date
    AND papf.effective_end_date
    AND TRUNC(SYSDATE) BETWEEN paaf.effective_start_date
    AND paaf.effective_end_date
    AND TRUNC(SYSDATE) BETWEEN papf1.effective_start_date
    AND papf1.effective_end_date
    ) a
    where CONNECT_BY_ISCYCLE > 0
    CONNECT BY NOCYCLE PRIOR a.person_id = a.supervisor_id
    ORDER SIBLINGS BY a.person_id

  • Exception Condition "Table_not_Exist" raised in query Level.

    Hi,
    I have a Hirarchy data in my Object level as below
    X
    ->   X1
         ->-> X001 (Values or at this level)
    I have created a variable on this object in the query level ( Entry is Optional) and executing the query.then I am getting the error mesage  Exception Condition "Table_not_Exist" raised.
    If I am putting the Variable Value as x* then query is displaying values properly .If i am not giving any values then error is coming. and without variable also executing but values in the output showing X001 lvel.
    So plz get back to me with the solution.
    "Appritiate Your help inadvance"
    Regards
    Ram.
    Edited by: Ramakanth Deepak Gandepalli on Dec 21, 2009 10:59 AM

    Hi,
    Please check the link below:
    http://www.saptechies.com/sap-47-installation-error-ora00942-table-or-view-does-not-exist/
    -Vikram Srivastava

  • Remove Hirarchy validity in WAD Template

    I my query in the WAD is the organizational unit with hirarchy. Here, the validity of which is shown as attribute. The validity will not be displayed. In Bex analyzer Excel Workbook can this be removed.
    How can I remove this in the WAD?
    regards
    Kerim

    Hi,
    i think you need to re add your changed bex query to wad template.
    Thanks

  • Time dependent Hirarchy Structure

    Hi,
    I need to create Hirarchy, i did not create before,
    Please some one explaine me how to create     Time dependent Hirarchy Structure  in CostCenter InfoObject.
    Please, please help me.
    Thanks

    HI
    Find the below link
    http://help.sap.com/saphelp_nw2004s/helpdata/EN/0e/fd4e3c97f6bb3ee10000000a114084/frameset.htm
    Time-Dependent Hierarchies  
    Use
    In a hierarchy that is not time dependent, the characteristic values are always the same.
    If you want to create views of a hierarchy that are valid for a specific time period, you need to create the entire hierarchy as time dependent.
    If you want to model relationships that change time-dependently, you need to create the hierarchy structure time-dependently.
    Functions
    In InfoObject maintenance, you can set whether and in which ways a hierarchy is time dependent. You can choose from the following:
    ·         whether the hierarchy is not time dependent (Hierarchy Not Time-Dependent). This is set by default.
    ·         whether the entire hierarchy is time dependent (Entire Hierarchy Time-Dependent).
    ·         whether individual node relationships are time dependent (Hierarchy Structure Time-Dependent)
    ·         whether a temporal hierarchy join is used with time-dependent hierarchy structures (Use Temporal Hierarchy Join)
    Entire Hierarchy is Time-Dependent
    You can either load time-dependent hierarchies (see Loading Time-Dependent Hierarchies) or create them in the BI system (see Creating a Hierarchy). When you create a time-dependent hierarchy, you have to enter a validity interval (valid to and valid from fields).
    If an entire hierarchy is time dependent, the system creates hierarchy versions that are valid for separate intervals. The system automatically uses the current valid version in this case. The hierarchy valid in each case can be uniquely identified by its technical name and the From-To Date.
    In the InfoObject tree of the Data Warehousing Workbench, all time-dependent hierarchies under the associated InfoObject are displayed with the corresponding To Date, for example  Time-Dependent Hierarchy 05/31/2000.
    In reporting, the system returns the valid hierarchy when a query is executed using the query key date.
    Within a restructuring company areas, you can create time-dependent versions of a hierarchy for the Main Area InfoObject. This enables you to compare the restructuring over different time periods in a query.
    Time-dependent hierarchy 01/01/1999 - 05/31/1999
    Time-Dependent Hierarchy 06/01/1999 - 12/31/1999
    Main Area NORTH
    Main Area NORTH
    Area 1
    Area 2
    Area 2
    Main Area SOUTH
    Main Area SOUTH
    Area 1
    Area 3
    Area 3
    Area 4
    Area 4
    In reporting, you can work in the individual columns of the report structure with fixed date values. You may want to do this to compare Main Area North in the Time-Dependent Hierarchy 05/31/2000 with Main Area North in the Time-Dependent Hierarchy 06/01/2000 (simulation).
    Time-Dependent Hierarchy Structures
    You can either load time-dependent hierarchies (see Loading Time-Dependent Hierarchies) or create them in the BI system (see Creating a Hierarchy).
    In hierarchy maintenance, you can determine a valid time interval for each hierarchy node (Valid to and Valid from fields).
    In reporting, a hierarchy with time-dependent hierarchy structures is created either for the current key date or for the key date defined for the query. In addition, you can evaluate a hierarchy historically using the temporal hierarchy join.
    You can assign an employee to different cost centers at different times within the context of a restructuring.
    In the context menu of a hierarchy, choose Display Hierarchy to access the hierarchy display: Each node and leaf has been given a date symbol. Hierarchy nodes that are assigned to different places in the hierarchy structure, depending on the time, are displayed more than once. By double clicking on a hierarchy node, you can display the associated validity period for the node relation.
    In the following example, you can double click on the Jones leaf to see that the worker Jones was assigned to region USA between 01/01/1999 and 05/31/1999 and Puerto Rico from 06/01/1999 to 12/31/1999.
    In order to use a hierarchy with a time-dependent hierarchy structure in reporting, you require the following settings in the BEx Query Designer:
                                a.      If you want to evaluate a hierarchy with a time-dependent hierarchy structure for a fixed key date, enter the key date in query definition.
                                b.      If you want to evaluate a hierarchy with a time-dependent hierarchy structure historically, for a key date that is to be derived from the data, choose the temporal hierarchy join option and specify the derivation type for the key date.
    For a more detailed description of the functions and differences between the two evaluation views, see Time-Dependent Hierarchy Structures in the Query.
    In maintenance of the key date derivation type (RSTHJTMAINT) determine the rule you want to use to determine the key date from the data. In this way you determine the time characteristic and way in which the key date is to be derived.
           1.      First determine the time characteristic.
    If you choose a Basic Time Characteristic as a time characteristic (for example, 0CALDAY, 0CALMONTH, 0FISCPER), you can use a key date derivation type of this kind for all InfoProviders that contain exactly one time characteristic that references the selected basic time characteristic. If there are several time characteristics in an InfoProvider that reference the basic time characteristic, you have to either determine the time characteristic more specifically or select a particular time characteristic from a particular InfoSet (Time Characteristic from InfoSet).
           2.      Determine how you want the key date to be derived from the time characteristic.
    The following derivation types are available:
    ¡        First day of the period
    ¡        Last day of the period
    ¡        Delay by number of days (you specify this in the Delay by Days field). In this case, the key date is calculated from the first day in the period plus the number of days specified minus 1. If the key date does not fall within the period, the last day of the period is used.
    Key date derivation type with (basic characteristic = 0CALMONTH, derivation type = u201Cfirst day of periodu201C):
    ·         For January 2005 the key date is calculated as 1/1/2005.
    ·         For February 2005 the key date is calculated as 2/1/2005.
    Key date derivation with (basic characteristic = 0FISCPER, derivation type = u201Cdelay by number of daysu201C and u201Ddelay u201C = 29):
    ·         For K4/01.2005 the key date is calculated as 1/29/2005.
    ·         For K4/02.2005 the key date is calculated as 2/28/2005.
    ·         For K4/03.2005 the key date is calculated as 3/29/2005.
    Note that the way in which you determine the key date derivation type affects performance. The number of data records that the OLAP processor reads corresponds to the level of detail on which the time characteristic and the leaf level lie. For this reason, choose the time characteristic as approximately as possible in order to keep the hierarchy small.
    A small hierarchy has 100 leaves. For a period of 12 months, the OLAP Processor reads 1200 data records at month level. At day level, it reads 36500 data records.
    Regards,
    kumar reddy.k
    Edited by: kumar reddy on Nov 18, 2008 10:50 AM

  • Error while running a query-Input for variable 'Posting Period is invalid

    Hi All,
    NOTE: This error is only cropping up when I input 12 in the posting period variable selection. If I put in any other value from 1-11 I am not getting any errors. Any ideas why this might be happening?
    I am getting the following error when I try and run a query - "Input for variable 'Posting Period (Single entry, mandatory)' is invalid" - On further clicking on this error the message displayed is as follows -
    Diagnosis
    Variable Posting Period (Single Value Entry, Mandatory) is used as a lower limit (X) and an upper limit () in an interval selection. This limit has the value #.
    System Response
    Procedure
    Enter a different value for variable Posting Period (Single Value Entry, Mandatory). If the value of the other limit is determined by another variable, you can change its value also.
    Procedure for System Administration

    OK.
    Well, if the variable is not used in any interval selection, then I would say "something happened to it".
    I would make a copy of the query and run it to check if I get the same problem with period 12.
       -> If not, something is wrong in the original query (you can proceed as below, if changes to original are permitted).
    If so, then try removing the variable completely from the query and hardcode restriction to 12.
       -> If problem still persists, I would have to do some thinking.
    If problem is gone, then add the variable again. Check.
       -> If problem is back, then the variable "is sick". Only quick thing to do, is to build an identical variable and use that one.
    If problem also happens with the new variable, then it's time to share this experience with someone else and consider raising an OSS.
    Good luck!
    Jacob
    P.S: what fisc year variant are you using?
    Edited by: Jacob Jansen on Jan 25, 2010 8:36 PM

  • Logical database in adhoc query

    Hello All,
    Can anyone tell me what is the logical database in adhoc query?

    Hi
    When you create a query , you have to select an infoset. Infoset can be considered as a source from which data is populated in the Query Fields.
    Infosets are created from Transaction SQ02.
    There can be four methods through which an Infoset can become a source of data:
    1.  Table join ( By joining two or more tables from Data dictionary)
         example: Joining tables PA0001 and PA0006 on Pernr to get a one resultant dataset
    2. Direct read of Basis Table ( Like PA0001 as a source for data in Infoset )
    3. Logical Database ( A Pre-written Program by SAP that extract data from clusters, tables taking care of authorizations and validity periods)
    Example : Logical database PNP, PNPCE (Concurrent Employement),PCH ( LDB for Personnel Development Data)
    Custom Logical DBs can be created in T_Code SE-36.
    4. Data Retrieval by a Program ( Custom code written by ABAP developers which will collect and process data) . This program has a corresponding Structure in data dictionary and the fields of this structure will be used in query)
    Reward Points, if helpful.
    Regards
    Waseem Imran

  • Query help on Goods Receipt Query with AP Invoice

    Looking for a little help on a query.  I would like to list all the goods receipts for a given date range and then display the AP Invoice information (if its been copied to an AP Invoice).  I think my problem is in my where clause, I plagerized an SAP query to show GR and AP from a PO as a start.  SBO 2005 SP01.  Any help would be great appreciated.  Thanks
    SELECT distinct 'GR',
    D0.DocStatus,
    D0.DocNum ,
    D0.DocDate,
    D0.DocDueDate,
    D0.DocTotal,
    'AP',
    I0.DocStatus,
    I0.DocNum ,
    I0.DocDate,
    I0.DocDueDate,
    I0.DocTotal,
    I0.PaidToDate
    FROM
    ((OPDN  D0 inner Join PDN1 D1 on D0.DocEntry = D1.DocEntry)
    full outer join
    (OPCH I0 inner join PCH1 I1 on I0.DocEntry = I1.DocEntry)
    on (I1.BaseType=20 AND D1.DocEntry = I1.BaseEntry AND D1.LineNum=I1.BaseLine))
    WHERE
    (D1.BaseType=22 AND D1.DocDate>='[%0]' AND D1.DocDate<='[%1]')
    OR (I1.BaseType=20 AND I1.BaseEntry IN
    (SELECT Distinct DocEntry
    FROM PDN1 WHERE BaseType=22 AND DocDate>='[%0]' AND DocDate<='[%1]'))

    Hi Dalen ,
    I  believe it is because of the condition
    (D1.BaseType=22 AND D1.DocDate>='%0' AND D1.DocDate<='%1')
    OR (I1.BaseType=20 AND I1.BaseEntry IN
    (SELECT Distinct DocEntry FROM PDN1 WHERE PDN1.BaseType=22 AND DocDate>='%0' AND DocDate<='%1'))
    Try changing
    D1.BaseType=22 OR D1.DocDate>='%0' AND D1.DocDate<='%1
    PDN1.BaseType=22 OR DocDate>='%0' AND DocDate<='%1'))
    Lets see what would be the result . Lets have some fun with troubleshooting
    See what would be the difference in the result .
    Thank you
    Bishal

  • Can you check for data in one table or another but not both in one query?

    I have a situation where I need to link two tables together but the data may be in another (archive) table or different records are in both but I want the latest record from either table:
    ACCOUNT
    AccountID     Name   
    123               John Doe
    124               Jane Donaldson           
    125               Harold Douglas    
    MARKETER_ACCOUNT
    Key     AccountID     Marketer    StartDate     EndDate
    1001     123               10526          8/3/2008     9/27/2009
    1017     123               10987          9/28/2009     12/31/4712    (high date ~ which means currently with this marketer)
    1023     124               10541          12/03/2010     12/31/4712
    ARCHIVE
    Key     AccountID     Marketer    StartDate     EndDate
    1015     124               10526          8/3/2008     12/02/2010
    1033     125               10987         01/01/2011     01/31/2012  
    So my query needs to return the following:
    123     John Doe                        10526     8/3/2008     9/27/2009
    124     Jane Donaldson             10541     12/03/2010     12/31/4712     (this is the later of the two records for this account between archive and marketer_account tables)
    125     Harold Douglas               10987          01/01/2011     01/31/2012     (he is only in archive, so get this record)
    I'm unsure how to proceed in one query.  Note that I am reading in possibly multiple accounts at a time and returning a collection back to .net
    open CURSOR_ACCT
              select AccountID
              from
                     ACCOUNT A,
                     MARKETER_ACCOUNT M,
                     ARCHIVE R
               where A.AccountID = nvl((select max(M.EndDate) from Marketer_account M2
                                                    where M2.AccountID = A.AccountID),
                                                      (select max(R.EndDate) from Archive R2
                                                    where R2.AccountID = A.AccountID)
                   and upper(A.Name) like parameter || '%'
    <can you do a NVL like this?   probably not...   I want to be able to get the MAX record for that account off the MarketerACcount table OR the max record for that account off the Archive table, but not both>
    (parameter could be "DO", so I return all names starting with DO...)

    if I understand your description I would assume that for John Dow we would expect the second row from marketer_account  ("high date ~ which means currently with this marketer"). Here is a solution with analytic functions:
    drop table account;
    drop table marketer_account;
    drop table marketer_account_archive;
    create table account (
        id number
      , name varchar2(20)
    insert into account values (123, 'John Doe');
    insert into account values (124, 'Jane Donaldson');
    insert into account values (125, 'Harold Douglas');
    create table marketer_account (
        key number
      , AccountId number
      , MktKey number
      , FromDt date
      , ToDate date
    insert into marketer_account values (1001, 123, 10526, to_date('03.08.2008', 'dd.mm.yyyy'), to_date('27.09.2009', 'dd.mm.yyyy'));
    insert into marketer_account values (1017, 123, 10987, to_date('28.09.2009', 'dd.mm.yyyy'), to_date('31.12.4712', 'dd.mm.yyyy'));
    insert into marketer_account values (1023, 124, 10541, to_date('03.12.2010', 'dd.mm.yyyy'), to_date('31.12.4712', 'dd.mm.yyyy'));
    create table marketer_account_archive (
        key number
      , AccountId number
      , MktKey number
      , FromDt date
      , ToDate date
    insert into marketer_account_archive values (1015, 124, 10526, to_date('03.08.2008', 'dd.mm.yyyy'), to_date('02.12.2010', 'dd.mm.yyyy'));
    insert into marketer_account_archive values (1033, 125, 10987, to_date('01.01.2011', 'dd.mm.yyyy'), to_date('31.01.2012', 'dd.mm.yyyy'));
    select key, AccountId, MktKey, FromDt, ToDate
         , max(FromDt) over(partition by AccountId) max_FromDt
      from marketer_account
    union all
    select key, AccountId, MktKey, FromDt, ToDate
         , max(FromDt) over(partition by AccountId) max_FromDt
      from marketer_account_archive;
    with
    basedata as (
    select key, AccountId, MktKey, FromDt, ToDate
      from marketer_account
    union all
    select key, AccountId, MktKey, FromDt, ToDate
      from marketer_account_archive
    basedata_with_max_intervals as (
    select key, AccountId, MktKey, FromDt, ToDate
         , row_number() over(partition by AccountId order by FromDt desc) FromDt_Rank
      from basedata
    filtered_basedata as (
    select key, AccountId, MktKey, FromDt, ToDate from basedata_with_max_intervals where FromDt_Rank = 1
    select a.id
         , a.name
         , b.MktKey
         , b.FromDt
         , b.ToDate
      from account a
      join filtered_basedata b
        on (a.id = b.AccountId)
    ID NAME                     MKTKEY FROMDT     TODATE
    123 John Doe                  10987 28.09.2009 31.12.4712
    124 Jane Donaldson            10541 03.12.2010 31.12.4712
    125 Harold Douglas            10987 01.01.2011 31.01.2012
    If your tables are big it could be necessary to do the filtering (according to your condition) in an early step (the first CTE).
    Regards
    Martin

Maybe you are looking for

  • Images Rotated 90 Degrees on prints

    i am having this issue with the Apple version of Adobe Illustrator CS3. We just got a new printer (Sharp MX-3501N) and it has a Fiery 2 print server on it. When i print illustrator documents to it, the first page comes out great. Comes out landscape

  • Regarding POPUP WINDOW.

    Hi, I have a requirement wherein after the user enters the values in the selection screen and executes the report, an output box must appear with the default value 100 which shows the number of records the user wants to view in the ALV display. The u

  • Getting back the review quiz-button

    Hello, Somehow I deleted the review quiz-button that is shown in the Quiz result-slide. How would I get it back? It happened a while back so Ctrl+Z is long gone . As I can't add any new buttons in a question slide, I can't work it out that way either

  • Why won't my iphoto events drag into google plus or shutterfly

    I have been trying to drag my photos from an event file in iphoto onto either Shutterfly or Google Plus, and I cannot do it.  I used to be able to do it with no problem, but it will not work any longer - for about a year, actually.  Any ideas of why

  • I renamed an iMovie '13 project in Finder, and now my work is erased?

    I'm really new to the latest version of iMovie (I had previously been using iMovie HD, which I guess is from 2006?), and I'm trying to figure things out. I had worked for hours on a project today, but then realized I had named it incorrectly, so I tr