Number of records under a hierarchy node

Hi,
Does anybody know of an easy way to measure the complexity of a hierarchy node (e.g number of entries below and depth)? I looked in the Hierarchy table but it does not seem too simple to analyze. This is for some performance tuning issue.
Thanks a lot,
Patrick

Hi Patrick,
I know you can use the data manager tool and check in there under either the free form search or the field search to find the records for each hierarchy.
-Dave

Similar Messages

  • SAP BEx - Reporing - Hierarchy - nodes repead the details

    Hello out there,
    I got the problem, that I want to create a BEx Query which got in the rows a characteristic with a hierarchy and below an oher one without hierarchy. For every different entity in the second characteristic I got the corresponding number of records under the sheet of the hierarchy. That is ok. In the notes of the hierarchy the system will not aggregate on the basis of the first characteristic entities. That is also ok, but in my case not required. I went through all the settings and checkt the help and the sdn without success.
    The following solution is also not helpful:
    - The second characteristic would be an attributes of the first one
    A solution will be appreciated.
    With kind regards,
    Marco

    Hello,
    I want to achieve, that the nodes (hierarchy of the first characteristic) show one row with the aggregated value. So the entities of the second characteristic on the level of the sheets are not considered on the level of the corresponding nodes. With other words, the hierarchie shows only the detail of the second characteristics on the level of the sheets.
    Hope this clarify my requirements. I appreciate any ideas.
    Many Thanks and kind regards,
    Marco
    Edited by: Marco Schraner on Aug 25, 2011 5:51 PM
    Edited by: Marco Schraner on Aug 25, 2011 5:53 PM
    Edited by: Marco Schraner on Aug 25, 2011 5:54 PM
    Edited by: Marco Schraner on Aug 25, 2011 5:54 PM

  • Refreshing Hierarchy node variable in BEx query with change in hierarchy

    Hi all,
    We have used a hierarchy node variable on Characteristic ZECCSAC (user-defined) and used it in a BEx query with default value set to a particular node value. Upto this, it is working fine.
    The hierarchy used in the query, with the hierarchy node variable, was later changed ( and in future it can undergo changes ). Since the number of records in the hierarchy are changing, the nodenames of the hierarchy nodes are changing. But the hier node variable default value is still set to the earlier nodename for that node description. So at runtime it is giving an error "ECCS Account Number is invalid"!
    Can anyone suggest how to refresh a hierarchy node variable default value each time a query is run so that the latest nodename is always taken ?
    Quick reply will be appreciated.
    Thanks

    Hi,
    You get this with User exits.
    Thnaks

  • Dynamic columns in query depending on hierarchy nodes

    Hello all
    I want to design a query with dynamic number of columns depending on hierarchy node.
    A hierarchy node is selected while running the query and user has authorization to see all subsequent nodes below the selected node.
    e.g. consider grp hierarchy with units and sub-grps as nodes.
    level1 Grp1
    levele2 unit1     :       grp2               :      grp3
    level3              :      unit2   unit4      :    unit4 grp4
    Suppose user select node Grp1, then there should be 3 columns for unit1, grp2, grp3
    If user selects node grp2, then there should be 2 columns for unit2 and unit4
    Please help. Any suggestions highly are highly appreciated.
    Rgds
    Sanjyot

    Surekha,
    Try this.
    Place heirarchy/characteristic in columns, under this place required keyfigure.
    Restrict with variable.
    Srini

  • Restric to hierarchy nodes and characteristics at the same time

    Hi together,
    I've got a profit center hierarchy and an authorization object with those fields:
    0CO_AREA
    0PROFIT_CTR
    0TCTAUTHH
    The controling area is compounded to the profitcenter.
    Then I created an authorization definition for hierarchies where i added a node from my profit center hierarchy.
    But aditionaly I want to add a single Profit center, which is not below this node. but it does not work. I only get the profit centers below the node i maintained for the hierarchy authorization and not the single entry for the profit center
    How can I setup this situation where I need to maintain on the one side one or more nodes in a hierarchy and then a single profit center which might be under another hierarchy node although this node is not explicitly allowed?
    Kind regards
    Stefan

    Thanks for the reply.  This issue is becoming a major problem for lots of implementations.  I have sent out several forum and OSS on this but no solution.

  • How to update unique number to records coming under 1 Hierarchy?

    Hi,
    I have the below table ,
    CREATE TABLE  TEMP2
      ID        NUMBER,
      MATCH_ID  NUMBER,
      UniqueID    NUMBER
    below records available in the table temp2,
    ID     MATCH_ID     UNIQUEID
    1     2     
    1     3     
    1     4     
    2     5     
    3     7     
    5     9     
    10     11     
    12     13     
    SET DEFINE OFF;
    Insert into TEMP2
       (ID, MATCH_ID, UNIQUEID)
    Values
       (1, 2, NULL);
    Insert into TEMP2
       (ID, MATCH_ID, UNIQUEID)
    Values
       (1, 3, NULL);
    Insert into TEMP2
       (ID, MATCH_ID, UNIQUEID)
    Values
       (1, 4, NULL);
    Insert into TEMP2
       (ID, MATCH_ID, UNIQUEID)
    Values
       (2, 5, NULL);
    Insert into TEMP2
       (ID, MATCH_ID, UNIQUEID)
    Values
       (3, 7, NULL);
    Insert into TEMP2
       (ID, MATCH_ID, UNIQUEID)
    Values
       (5, 9, NULL);
    Insert into TEMP2
       (ID, MATCH_ID, UNIQUEID)
    Values
       (10, 11, NULL);
    Insert into TEMP2
       (ID, MATCH_ID, UNIQUEID)
    Values
       (12, 13, NULL);
    COMMIT;
    requirement :
    id 1 is matching with matchID 2,3,4 and 2 is matching with 5 and 3 is matching with 7 and 5 is matching with 9
    here I want to give one unique sequnce to all the related hierarchy records,
    How can i do this?
    my output should like this,
    ID     MATCH_ID     UNIQUEID
    1     2     1
    1     3     1
    1     4     1
    2     5     1
    3     7     1
    5     9     1
    10     11     2
    12     13     3
    Any help appriciated..

    You want something like this?
    SQL> ed
    Wrote file afiedt.buf
      1  select id, match_id, dense_rank() over (order by par_id) as rnk
      2  from (
      3        select id, match_id, connect_by_root(id) as par_id
      4        from   temp2
      5        connect by nocycle id = prior match_id
      6  --      start with id not in (select match_id from temp2)
      7       )
      8* order by rnk
    SQL> /
            ID   MATCH_ID        RNK
    612646357  612663043          1
    612663043  612646357          1
    612646600  612673275          2
    612673275  612646600          2
    612646602  612660746          3
    612660746  612646602          3
    612646816  612661509          4
    612661509  612646816          4
    612660746  612646602          5
    612646602  612660746          5
    612661509  612646816          6
    612646816  612661509          6
    612663043  612646357          7
    612646357  612663043          7
    612673275  612646600          8
    612646600  612673275          8
    16 rows selected.

  • DSO or ODS "Insert New Hierarchy Nodes" under Data Fields

    When you insert info objects under the Data Fields in DSO right mouse click on the Data Fields icon and you will find Insert New Hierarchy Nodes . I created a hierarchy node with infoobjects associating with it which will be visible under the Filters Folder in BEx Query designer as a seperate folder. I can add them to the infoobjects from this folder into the query. I did not know how to apply this functionality in Queries and what it really does. My guess was you can create dynamic hierarchy using characteristic infoobjects from transactional data.Any ideas or links to documentation. This option was available from 7.X in DSO's and i think even in 3.x ODS.

    Hi,
    May help you:----
    http://help.sap.com/saphelp_nw70/helpdata/en/4a/e71f39488fee0ce10000000a114084/content.htm
    You could feel the flexibility of using this hierarchial display in the Query. Try to create any Query on this DSO.
    Regards,
    Suman

  • Vendor Hierarchy - Creating Master Record for a Vendor Hierarchy node

    Hi gurus,
    I have configured the Vendor hierarchy as per procedure.
    What is the T code/path to create the master record for a vendor hierarchy node? Also please let me know the procedure to map the existing vendors to the hierarchy.
    Thanks and regards
    Durai

    Hi Gurus,
    Your help would be greatly appreciated. Please throw your inputs.
    Thanks and regards
    Durai

  • Hierarchy datasource is showing wrong number of records

    Hi,
    I have to load hierarchies from r/3 to BW.when i test my hierarchy DataSource in RSA6 number of records its showing is 40,where as my R/3 system has 45 records for the same hierarchy.Can any one please let me know why its showing different number of records and how to overcome this problem.

    Hello VaKa,
    How r u ?
    Just load the data to the PSA and identify which records are missing, you can do this, u have small amount of data. Then you can identify which 5 records are missing and it will help to find the reason as well.
    Best Regards....
    Sankar Kumar
    +91 98403 47141

  • Reassignment of hierarchy nodes dynamically

    Hi Experts,
    I have a requirement wherein I need to re-assign the hierarchy node for an account based on Functional area.
    Currently, we load 0ACCOUNT info object with hierarchy defined in KDH3 transaction in R/3. Here, the account 650000000 is defined under local accounts node of the hierarchy. Hence, when we use the 0account infobject in BEx with hierarchy activated, all the records in transaction data with account no. 650000000 are aggregated under local accounts node.
    However, the user wants us to check the functional area for each of the record with 65000000 account and re-assign it to a different node of the hierarchy. For example, if the transaction data has account number 65000000 and functional area 400, then the record needs to be aggregated under a different node in hierarchy, say overhead costs. Similarly, if there is another record with account 650000000 and functional area 300, then the record needs to be aggregated under Sales & marketing.
    How do we handle such conditional assignment of hierarchy nodes?
    Regards,
    SS

    Hi,
    I really doubt if dynamic reassignment of hierarchy nodes is possible in BW, but could be wrong.
    Alternatives which you can consider
    a. A flat hierarchy modeled in the dimension of the cube i.e. higher levels of 0ACCOUNT can be filled during transformations based on functional area. Major disadvantage here is that any change to the hierarchy or assignment could require reloads depending on your requirement i.e. touch history data or not
    b.Customized Hierarchy created by combining the original hierarchy and the assignment details
    for eg 
    Leaf Node: 650000000_400 under parent Overhead Costs
    Leaf Node: 650000000_300,under parent Sales & Marketing
    Regards,
    Advait

  • Run Time Error when trying to select hierarchy node

    Hy all,
    the situation is the following:
    i attempt to create a variable of type "hierarchy node" (for cost center cha) in my planning area, i used the replacement type "user defined value", check on "input allowed by user" and then i create the user entry, in selection condition i run match code and when i try to select a single cost center (not a hierarchy node) expanding the hierarchy tree the system goes dump with the following message:
    Runtime Errors         MESSAGE_TYPE_X
    Error analysis
    Short text of error message:
    Program is inconsistent -> see long text
    Technical information about the message:
    Diagnosis:
    An inconsistent program status has occurred. The program cannot be continued.
    System response:
    The system crashes.
    Procedure
             1.  Look in OSS for a note under the error message UPC099.
             2.  When you open a problem message, send the first pages of the
                 system crash message including the section 'Source code excerpt
                 ' with the message.
         Procedure for System Administration
        Message classe...... "UPC"
        Number.............. 099
    Selecting a hierarchy node (not a single cost center but a text node grouping more cost conter) this problem does not occur.
    I appreciate (and reward) any hints.
    Thanks in advance
    Fabio

    Hi,
    Go through the oss notes with error message UPC099
    Dump during hierarchy selection:<b>536694</b>
    Dump when reading a hierarchy with intervals :<b>423953</b>
    Regards-
    Siddhu
    Message was edited by: sidhartha

  • Hierarchy Node Intial load from R/3 to CRM 5.2

    Hi
    I have this problem when download form R/3 4.6c to CRM 5.2 hierarchy node.
    Can you help me?
    It's very important because we are blocked.
    Thanks
    Best regards.
    we downloaded the following customer hierarchy:
    0002189004
    - 0002199004
    - 0002190509
    - 0002010050
    using the object DNL_BUPA_KNVH.
    In this way the table CRM_KNVH_TEMP has been filled correctly with all
    the structure.
    We executed the BPH_DNL transaction selecting only the hierarchy type
    D,
    and the sales org D468, distr chann 01 , divsion 99.
    After saving the hierarchy we created all the hierarchy structure in
    CRM but there are not any customers linked to the related hierachy node.In particular we found the followng situation:
    table BUT_HIER_NODE, filled with all the hierarchy node
    table BUT_HIER_NODE_D fille with all the descrption of the hiarachy
    node in english language
    table BUT_HIER_STRUCT filled with the structure and the link between
    node
    tables BUT_HIER_TREE,. BUT_HIER_TREE_d filled with all our hiearcy type
    table BUT_HIER_NODE_BP empty
    also:
    the method "assign_bp_to_node" is only executed in the the private
    method
    "change_record" but it is commented in the method "create record" and
    also
    "build_crm_tree".
    In conclusion the method "start_initial_down_load2 (executed int the
    function CRM_BUHI_INITIAL_DOWNLOAD) call the method 2build_crm_tree2,
    but this method never execute "assign_bp_to_node".

    I have found a propoer articulation of my problem in SAP note 429423. It goes as follows:
    <i>"No entry exists in one of the queues, but the status in R3AM1 remains 'Running':
    In this case, probably no reply is sent to the CRM Server after the data selection in the source system.If this is the case for an adapter object but not for others, contact the respective application component which can analyze why the source system does not send a reply and correct it.
    If this system response occurs for all adapter objects, create a message for component CRM-MW-ADP."</i>
    However, I am unable to act on the above. Kindly suggest what exactly needs to be done as suggested in the note.

  • Creation of  Variable for Hierarchy Node

    Greetings...fellow matez,
       I am using Characteristic "0PROFIT_CTR" : PROFIT CENTER
       Here, I created used SAP <b>Standard</b> variable 0N_PCTR (Profit Center/Profit Center Hierarchy)
       This meets my requirement of allowing User to Input the TOP MOST Hierarchy Node basically means my Hierarchy.
       Now, what I need is the ability of a User Input/Key In Variable to ask for a specific Node of my Hierarchy instead of just the <b>'main'</b> hierarchy
      Let me demonstrate with an example :-
      At the moment, I have a variable defined for "0PROFIT_CTR". So, I am able to choose "XXX GROUP" as my hierarchy.
      Now, under this "XXX Group" I have several Sub-Nodes like XXX-Functional Groups ; XXX-Business Units; XXX-Subsidaries.
      How can I create a variable which prompts for this Subnodes of my hierarchy ?

    Matez,
      Issue remains unresolved.
      What I need is a <b>Hierarchy - NODE</b> variable for my "Profit and Loss" Hierarhy
      But, when I use the variable option in the 'Selecting Variable for Hierarchy' scree, I only get to choose my Hierarchy instead of my Hierarchy Node.
      How can I created a variable of type Hierarchy-NODE instead of Hierarchy for my characteristic "0Account"
    Kindly advice matez!

  • How to find the total number of pair under particular parent according to pattern 1:2or2:1,1:1 day to day maximum up to 5 pair caping daily

    Dear friends,
    I provide full details here ,my database table structure ,data and stored procedure and my problem ,
    please review it and provide the solution or any idea to solve my problem.
    I am working on a project in which members are added in a tree pattern, and get the payment accordingly.
    below is my table structure ,data and stored procedure
    CREATE TABLE Associate_Income
    ID varchar(30) NOT NULL,
    ParentID varchar(30) NULL,
    IsLeft tinyint NULL,
    IsRight tinyint NULL,
    joingdate datetime NOT NULL
    go
    INSERT Associate_Income
    (ID, ParentID, IsLeft, IsRight, joingdate)
    SELECT 'Ramesh123', NULL, NULL, NULL '2014-01-03 16:31:15.000' UNION ALL
    SELECT 'Sonu', 'Ramesh123', 1, NULL, '2014-01-03 16:45:21.000' UNION ALL
    SELECT 'Pawan kumar', 'Ramesh123', NULL, 1, '2014-01-04 16:50:23.000' UNION ALL
    SELECT 'Ravi123', 'Sonu', 1, NULL, '2014-01-04 17:03:22.000' UNION ALL
    SELECT 'Vineet123', 'Sonu', NULL, 1, '2014-01-04 17:26:01.000' UNION ALL
    SELECT 'dev123', 'Ravi123', 1, NULL, '2014-01-05 19:35:16.000' UNION ALL
    SELECT 'Mukesh123', 'Ravi123', NULL, 1, '2014-01-05 19:40:41.000' UNION ALL
    SELECT 'poonam123', 'Vineet123', 1, NULL, '2014-01-05 19:49:49.000' UNION ALL
    SELECT 'monu', 'Pawan kumar', 1, NULL, '2014-01-05 17:32:58.000' UNION ALL
    SELECT 'Arti123', 'Pawan kumar', NULL, 1, '2014-01-05 19:54:35.000' UNION ALL
    My  database table Associate_Income  structure and data is as follow:
    ID ParentID IsLeft IsRight joingdate
    Ramesh123 NULL NULL NULL 2014-01-03 16:31:15.000
    Sonu Ramesh123 1 NULL 2014-01-03 16:45:21.000
    Pawan kumar Ramesh123 NULL 1 2014-01-04 16:50:23.000
    Ravi123 Sonu 1 NULL 2014-01-04 17:03:22.000
    Vineet123 Sonu NULL 1 2014-01-04 17:26:01.000
    dev123 Ravi123 1 NULL 2014-01-05 19:35:16.000
    Mukesh123 Ravi123 NULL 1 2014-01-05 19:40:41.000
    poonam123 Vineet123 1 NULL 2014-01-05 19:49:49.000
    monu Pawan kumar 1 NULL 2014-01-05 17:32:58.000
    Arti123 Pawan kumar NULL 1 2014-01-05 19:54:35.000
    by using below stored procedure i can count the total number of pairs under particular node in 2:1,1:1 ratio means first pair is completed when two node added to the left side of given parent node and one node added
    right side of given parent node after that all pairs are completed when one node added left side and one node added right side of parent node (1:1 ratio)
    example if i execute my stored procedure as follows it would return following.
    EXEC count_pairs 'Ramesh123'
    3
    so there is 3 pairs as shown in my figure.
    when we execute my stored procedure for ParentID 'sonu' it would return following.
    EXEC count_pairs 'sonu'
    2
    so there is 2 pairs as shown in my figure.
    My problem is to find the query which can return the total number of pair under particular node any given parent  node. day to
    day maximum 5 pairs in a day please any one can suggest us
    CREATE proc [dbo].[count_pairs]
    @ParentID nvarchar(50)
    as
    begin
    Declare @ParentSUM SMALLINT = 0
    Declare @SubLeftID nvarchar(50)
    Declare @SubRightID nvarchar(50)
    SELECT @SubLeftID = CASE WHEN [IsLeft] = 1 THEN [ID] ELSE @SubLeftID END
    ,@SubRightID = CASE WHEN [IsRight] = 1 THEN [ID] ELSE @SubRightID END
    FROM Associate_Income
    WHERE ParentID = @ParentID
    IF @SubLeftID IS NOT NULL AND @SubRightID IS NOT NULL AND EXISTS(SELECT 1 FROM Associate_Income WHERE [IsLeft] = 1 AND ParentID = @SubLeftID)
    BEGIN
    SET @ParentSUM = 1
    ;WITH Associate_Income_CTE AS
    SELECT [ID], [ParentID], [IsLeft], [IsRight], 0 AS [Level]
    FROM Associate_Income
    WHERE [ParentID] = @ParentID
    UNION ALL
    SELECT RecursiveMember.[ID], RecursiveMember.[ParentID], RecursiveMember.[IsLeft], RecursiveMember.[IsRight], Level + 1
    FROM Associate_Income RecursiveMember
    INNER JOIN Associate_Income_CTE AnchorMember
    ON RecursiveMember.[ParentID] = AnchorMember.[ID]
    SELECT @ParentSUM = @ParentSUM + COUNT([ParentID])
    FROM
    SELECT [ParentID]
    ,'IsLeft' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsLeft] = 1
    AND [ID] <> @ParentID --AND [ID] NOT IN (@SubLeftID, @ParentID)
    AND [ParentID] NOT IN (@ParentID, @SubLeftID)
    UNION ALL
    SELECT [ParentID]
    ,'IsRight' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsRight] = 1
    AND [ParentID] <> @ParentID
    ) AS Associate_Income
    PIVOT
    MAX([Value]) FOR [Direction] IN ([IsLeft], [IsRight])
    ) PVT
    WHERE [IsLeft] IS NOT NULL AND [IsRight] IS NOT NULL
    END
    SELECT @ParentSUM
    Jitendra Kumar Sr. Software Developer at Ruvixo Technologies 7895253402

    I don't think this is homework, I am not sure how helpful it was by Kalman to merge the two threads. It appears that two different persons posted the questions. It could be though, that it is the same problem and Jitendra has taken over Chandra's
    task.
    However, I was not able to understand the problem nor the figure. And nor the definition of pairs in this context. My assumption is that what Jitendra posted is an abstraction of the actual problem in order to not reveal intellecutal property. Possibly this
    makes the problem more difficult to understand for us outsiders.
    I've come so far that I worked out a table definition and INSERT statements with sample data, as well as a call to the procedure which returns 3 and this appears to map to the figure, but I don't know what it means. Since I don't know what this
    is about, I have not made any attepmts to understand the code, but I would appreciate clarification about the underlying business rules as well as the expected results for various test cases.
    CREATE TABLE Associate_Income(ID varchar(30) NOT NULL,
    ParentID varchar(30) NULL,
    IsLeft tinyint NULL,
    IsRight tinyint NULL,
    joingdate datetime NOT NULL)
    go
    INSERT Associate_Income (ID, ParentID, IsLeft, IsRight, joingdate)
    SELECT 'Ramesh123', NULL, NULL, NULL, '2014-01-03 16:31:15.000' UNION ALL
    SELECT 'Sonu', 'Ramesh123', 1, NULL, '2014-01-03 16:45:21.000' UNION ALL
    SELECT 'Pawan kumar', 'Ramesh123', NULL, 1, '2014-01-04 16:50:23.000' UNION ALL
    SELECT 'Ravi123', 'Sonu', 1, NULL, '2014-01-04 17:03:22.000' UNION ALL
    SELECT 'Vineet123', 'Sonu', NULL, 1, '2014-01-04 17:26:01.000' UNION ALL
    SELECT 'dev123', 'Ravi123', 1, NULL, '2014-01-05 19:35:16.000' UNION ALL
    SELECT 'Mukesh123', 'Ravi123', NULL, 1, '2014-01-05 19:40:41.000' UNION ALL
    SELECT 'poonam123', 'Vineet123', 1, NULL, '2014-01-05 19:49:49.000' UNION ALL
    SELECT 'monu', 'Pawan kumar', 1, NULL, '2014-01-05 17:32:58.000' UNION ALL
    SELECT 'Arti123', 'Pawan kumar', NULL, 1, '2014-01-05 19:54:35.000'
    go
    CREATE proc [dbo].[count_pairs]
    @ParentID nvarchar(50)
    as
    begin
    Declare @ParentSUM SMALLINT = 0
    Declare @SubLeftID nvarchar(50)
    Declare @SubRightID nvarchar(50)
    SELECT @SubLeftID = CASE WHEN [IsLeft] = 1 THEN [ID] ELSE @SubLeftID END
    ,@SubRightID = CASE WHEN [IsRight] = 1 THEN [ID] ELSE @SubRightID END
    FROM Associate_Income
    WHERE ParentID = @ParentID
    IF @SubLeftID IS NOT NULL AND @SubRightID IS NOT NULL AND EXISTS(SELECT 1 FROM Associate_Income WHERE [IsLeft] = 1 AND ParentID = @SubLeftID)
    BEGIN
    SET @ParentSUM = 1
    ;WITH Associate_Income_CTE AS
    SELECT [ID], [ParentID], [IsLeft], [IsRight], 0 AS [Level]
    FROM Associate_Income
    WHERE [ParentID] = @ParentID
    UNION ALL
    SELECT RecursiveMember.[ID], RecursiveMember.[ParentID], RecursiveMember.[IsLeft], RecursiveMember.[IsRight], Level + 1
    FROM Associate_Income RecursiveMember
    INNER JOIN Associate_Income_CTE AnchorMember
    ON RecursiveMember.[ParentID] = AnchorMember.[ID]
    SELECT @ParentSUM = @ParentSUM + COUNT([ParentID])
    FROM
    SELECT [ParentID]
    ,'IsLeft' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsLeft] = 1
    AND [ID] <> @ParentID --AND [ID] NOT IN (@SubLeftID, @ParentID)
    AND [ParentID] NOT IN (@ParentID, @SubLeftID)
    UNION ALL
    SELECT [ParentID]
    ,'IsRight' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsRight] = 1
    AND [ParentID] <> @ParentID
    ) AS Associate_Income
    PIVOT
    MAX([Value]) FOR [Direction] IN ([IsLeft], [IsRight])
    ) PVT
    WHERE [IsLeft] IS NOT NULL AND [IsRight] IS NOT NULL
    END
    SELECT @ParentSUM
    END
    go
    EXEC count_pairs 'Ramesh123'
    go
    DROP PROCEDURE count_pairs
    DROP TABLE Associate_Income
    Erland Sommarskog, SQL Server MVP, [email protected]

  • ABAP query not returning correct number of records

    Hi,
    I have created an ABAP Query using logical database VFV and nodes VBRK, VBUK and VBRP.
    But, after entering values for Sales Organisation ( VBRK-VKORG ), Distribution channel ( VBRK-VTWEG ) and Date ( VBRK-FKDAT), the number of records that I get are very less in number as compared to the actual number in the database.
    Please give some pointers to the reason. I have set Lines 60 and Columns length - 83 and selected ALV List.
    Regards,
    Garima.

    Hi Garima,
    Please Check whether you are selecting all the Key fields in your Query.
    Thanks & Regards,
    Ashok kumar.

Maybe you are looking for