Bapi_costelementgrp_create and hierarchy nodes

Hi to all,
I need an algorythm in order to fill the internal table hierarchynodes (def. like bapiset_hier ) to pass to the bapi_costelementgrp_create.
The hierarchy nodes will be uploaded from a file with two fields: "father node" and "child node" like the following:
TESTJR     TESTJR2
TESTJR2   TESTJR3
TESTJR     TESTJR4
in the internal table the hierlevel shoul be like the following schema:
TESTJR is level 0
TESTJR2 have to assigned to TESTJR (hierlevel 1)
TESTJR3 have to assigned to TESTJR2 (hierlevel 2)
TESTJR4 have to assigned to TESTJR (hierlevel 1)
Any ideas and suggestions?
Thanks in advance.
Andrew

Hello Andrew,
Try the code below.  However, you should test it thoroughly.  WARNING:  Make sure first record in internal table pertains to the root node.  The internal table lt_hier is the internal table that you assign parameter "hierarchynodes" when calling BAPI_COSTELEMENTGRP_CREATE.
Kind Regards,
Rae Ellen Woytowiez
* Types, internal table, and structures for input file
TYPES:  BEGIN OF input,
          groupname1 TYPE bapiset_groupname,
          groupname2 TYPE bapiset_groupname,
        END OF input.
TYPES:  input_tt TYPE TABLE OF input.
DATA:  lt_input TYPE input_tt,
       ls_input TYPE input.
TYPES:  BEGIN OF input_numbered,
          groupname1 TYPE bapiset_groupname,
          groupname2 TYPE bapiset_groupname,
          rrn TYPE i,
        END OF input_numbered.
TYPES:  input_numbered_tt TYPE TABLE OF input_numbered.
DATA:  lt_input_numbered TYPE input_numbered_tt,
       ls_input_numbered TYPE input_numbered.
* Types, internal tables, structures used to help
* determine hierarchy level.
TYPES:  BEGIN OF group_level_numbered,
          level TYPE bapiset_level,
          rrn TYPE i,
          groupname TYPE bapiset_groupname,
        END OF group_level_numbered.
TYPES:  group_level_numbered_tt TYPE TABLE OF group_level_numbered.
DATA:  lt_group_level_numbered TYPE group_level_numbered_tt,
       ls_group_level_numbered TYPE group_level_numbered.
* Types, internal table, structures for function module.
TYPES:  bapiset_hier_tt TYPE TABLE OF bapiset_hier,
        bapi1113_values_tt TYPE TABLE OF bapi1113_values.
DATA:  lt_hier TYPE bapiset_hier_tt,
       lt_values TYPE bapi1113_values_tt,
       ls_hier TYPE bapiset_hier,
       ls_values TYPE bapi1113_values.
DATA:  count TYPE i.
DATA:  level TYPE i.
START-OF-SELECTION.
  count = 1.
  LOOP AT lt_input INTO ls_input.
    CLEAR:  ls_input_numbered.
    ls_input_numbered-groupname1 = ls_input-groupname1.
    ls_input_numbered-groupname2 = ls_input-groupname2.
    ls_input_numbered-rrn = count.
    APPEND ls_input_numbered TO lt_input_numbered.
    count = count + 1.
  ENDLOOP.
* Build hierarchy
  SORT lt_input_numbered BY groupname1 rrn.
  level = 0.
  LOOP AT lt_input_numbered INTO ls_input_numbered.
    PERFORM process_group
                USING
                   ls_input_numbered
                CHANGING
                   level.
  ENDLOOP.
* derive table to be used in FM
  SORT lt_group_level_numbered BY rrn.
  LOOP AT lt_group_level_numbered INTO ls_group_level_numbered.
    ls_hier-groupname = ls_group_level_numbered-groupname.
    ls_hier-hierlevel = ls_group_level_numbered-level.
    ls_hier-DESCRIPT = ls_group_level_numbered-groupname.
    APPEND ls_hier TO lt_hier.
  ENDLOOP.
FORM process_group USING value(ps_input_numbered) TYPE input_numbered
                   CHANGING value(pv_level) TYPE bapiset_level.
  DATA:  groupname1_subrc TYPE sysubrc,
         groupname1_tabix TYPE sytabix.
  DATA:  groupname2_subrc TYPE sysubrc,
         groupname2_tabix TYPE sytabix.
* Check and if necessary add groupname1.
  CLEAR ls_group_level_numbered.
  READ TABLE lt_group_level_numbered INTO ls_group_level_numbered
             WITH KEY groupname = ps_input_numbered-groupname1
             BINARY SEARCH.
  groupname1_subrc = sy-subrc.
  groupname1_tabix = sy-tabix.
  IF groupname1_subrc <> 0.
    ls_group_level_numbered-groupname = ps_input_numbered-groupname1.
    ls_group_level_numbered-level = pv_level.
    ls_group_level_numbered-rrn = ps_input_numbered-rrn.
    INSERT ls_group_level_numbered INTO lt_group_level_numbered
           INDEX groupname1_tabix.
  ELSE.
    pv_level = ls_group_level_numbered-level.
  ENDIF.
* Check and if necessary add groupname2.
  CLEAR ls_group_level_numbered.
  READ TABLE lt_group_level_numbered INTO ls_group_level_numbered
             WITH KEY groupname = ps_input_numbered-groupname2
             BINARY SEARCH.
  groupname2_subrc = sy-subrc.
  groupname2_tabix = sy-tabix.
  IF groupname2_subrc <> 0.
    ls_group_level_numbered-groupname = ps_input_numbered-groupname2.
    ls_group_level_numbered-level = pv_level + 1.
    ls_group_level_numbered-rrn = ps_input_numbered-rrn.
    INSERT ls_group_level_numbered INTO lt_group_level_numbered
           INDEX groupname2_tabix.
  ENDIF.
* Check for childs for groupname2.
  pv_level = pv_level + 1.
  LOOP AT lt_input_numbered INTO ls_input_numbered
                     WHERE groupname1 = ps_input_numbered-groupname2.
    PERFORM process_group
                USING
                   ls_input_numbered
                CHANGING
                   level.
  ENDLOOP.
ENDFORM.
Edited by: Rae Ellen Woytowiez on Apr 15, 2011 7:24 AM
Edited by: Rae Ellen Woytowiez on Apr 15, 2011 7:26 AM
Edited by: Rae Ellen Woytowiez on Apr 15, 2011 7:26 AM

Similar Messages

  • Hierarchy node not available in Query Designer

    Hello Gurus,
    I can find the hierarchy node variable in BW but it is not available in query designer. Does anyone know what might be the problem and a solution?
    Thanks,
    Mark

    Hi Mark,
    You said you "find the hierarchy node variable in BW but it is not available in query designer".
    How did you find the hierarchy node variable in BW? From backend SAPGUI, you will only be able to see the variable in some internal tables like RSZGLOBV. Did you mean this?
    For "it is not available in query designer", do you means that when you want to create a hierarchy node variable for this characteristic in Query Designer, you don't find this certain hierarchy node variable in the hierarchy node variable list?
    Important thing to notice is that, flat value variables and hierarchy node variables are listed separately. Did you make sure that you have chose to list hierarchy node variables in Query Designer?
    Regards,
    Patricia

  • Issue with hierarchy node variable and multiple SAP hierarchies

    Hello experts,
    We are currently facing an issue when using two SAP hierarchies in Web Intelligence and one of them is restricted with a hierarchy node variable.
    The systems we use are a SAP BI 7.01 (SPS 05) and a Business Objects Enterprise XI R3.1 SP2 (fix pack 2.3). I want also to point out that the fix pack 2.3 has been applied to all BOE related components: the SAP integration Kit, client tools, and enterprise (server and client).
    The universe used in our scenario is based on a BEX Query with two hierarchies (non-time dependent hierarchies, intervals allowed) loaded on their corresponding characteristics. One of these characteristics is restricted with a hierarchy node variable (manual input, optional, ready for input, multiple single values allowed). 
    Prerequisites for replicating the problem:
    1)     When building the web intelligence query select several levels from both hierarchies (they have seven levels each) and    the   only amount of the InfoCube that the BEX query (that was used to create our universe) relies on.
    2)     In the hierarchy node variable prompt select a hierarchy node entry (not an actual InfoObject value that exists as transactional data in the InfoCube )
    By executing the query built above, all characteristics are returned null (no value) and the key figure with value u201C0u201D. No error messages, no partial results warnings.  Now if we go back to u201CEdit queryu201D and select levels of only one of any of the two hierarchies the query runs normally (by selecting the exact same value for the hierarchy node variable prompt).
    Any ideas on the matter?
    Regards,
    Giorgos

    Hi,
    Have you ever got a solution for this problem?
    I have a similar one.
    Thanks,
    regards, Heike

  • Lack of texts in hierarchy nodes and leafs for 0ORGUNIT

    Hello experts!
    We have the BCT hierarchy 0ORGUNIT in BW exporting his time-dependent structure from R/3. Now, for some leafes and some nodes above the leaf we have no texts just see the key.
    Has someone an idea what the problem could be? In R/3 we have the text and in master data of 0ORGUNIT we also have the text within the right time period...
    Thanks for help!
    Best reagards,
    Peter

    I'm not sure I understand what you are suggesting. Here is the data we have:
    Hierarchy             Key Figure
    - CC 0001 (node)      30.56
      CC 0001 (leaf)          6.45
      - CC 0002 (node)       24.11
           CC 0002 (leaf)     6.45
           CC 0003 (leaf)     5.72
           CC 0004 (leaf)     7.47
           CC 0005 (leaf)     4.47
    We want the value 6.45 to show up next to the CC 0002 hierarchy node, since that is the value for that cc. And we want the 6.45 to show up against the cc 0001 node rather than adding everything beneath it. What you suggested below - is that a display option in the query, or where do I do it?
    Thanks.

  • Use of filters and aggregations based on hierarchy nodes in an update rule

    Hello,
    I need to calculate some indicators from a ODS (BW 3.5) that contain raw data to another one that will contain indicators. These figures are the results of the use of filters and aggregations based on hierarchy nodes (for example: all sales accounts under a node).
    In fact, this is typically a query but I want to store these figures, so I need
    I understood I have to use a start routine. I never did that before.
    Could you provide me with easy-to-understand-for-newbies examples of:
    - filtering data based on the value of an infoobject (value must be empty, for example)
    - filtering and aggregation of data based on the appartenance to hierarchy nodes (all sales figures, ....)
    - aggregation of the key figures based on different characteristics after filtering of these
    Well, I am asking a lot ...
    Thank you very much
    Thomas

    Please go through the following link to learn more on aggregates:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e55aaca6-0301-0010-928e-af44060bda32
    Also go through the very detailed documentation:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/67efb9bb-0601-0010-f7a2-b582e94bcf8a
    Regards,
    Mahesh

  • Cannot Include and exclude selectiion on hierarchy node in the Filter area

    Hi,
    When i open the query and execute it. and select the filter area for hierarchy nodes. The include and exclude selection is disabled in 3.5x analyzer. We are using BI 7.0 with SP 12. we just upgraded.
    Can you please help. is this functionality not available?
    Regards,
    Gaurav

    Hi Rob, you can do that for the query (the exclude selection) on the Query Designer. But its not recomended on performance point of view.
    hope this helps
    Natalia.

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

  • Download of hierarchy nodes and accounts from BW

    Hi,
    Does anyone know how to download a list of the hierarchy nodes and accounts out of BW? I need the list to work on some analysis and documentation.
    Thanks in advance.

    Hi Jackie,
    Have you seen this document:How to Download a Hierarchy to a Flat File
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/0403a990-0201-0010-38b3-e1fc442848cb
    Hope this helps...

  • Query with user-exit hierarchy variable and input ready hierarchy node var.

    Hello everyone.
    we are using several hierarchies (2005, 2006 and 2007) of the same info object 0FUNDS_CTR (one for each fiscal year). We would like to be able to use same reports regardless of chosen fiscal year (selected hierarchy) and ever more, to select node inside proper hierarchy. At the moment reports use 3 parameters:
    1) fiscal period from - fiscal period to
    2) hierarchy name
    3) hierarchy node
    Our goal is to get report with only 2 parameters:
    1) fiscal period from - fiscal period to
    2) hierarchy node
    since hierarchy name could be derived (user exit) from fiscal period.
    When user selects hierarchy node he is being asked to select hierarchy name (despite of user exit for hierarchy name) and key date (populated with current date).
    We would like to avoid step of user selecting hierarchy. Is it possible?
    Any other approaches to problem would be appreciated.
    Kind regards,
    Josko.

    Hi Jörg,
    As mentioned, I_STEP = 3 is  processed once per query, not once per varaiable.
    If this statement is placed within case-endcase for I_VNAM it never will be processed.
    Please take a look on this, it might be helpful..
    Regards
    Joe

  • Difference between hierarchy node and single value

    Hi experts,
    Can anyone explain me the difference between hierarchy node and single value?
    This is my problem:
    I have a query that uses a characteristic (0ORGUNIT) with a hierarchy and I execute it without any problem but when I try to set a fliter on this characteristic and I try to find a single value, for example 101, it doesn't appear in the single value list, instead it appears in the hierarchy nodes list in the selection window.
    I think I'm confused about both terms because I thought  a hierarchy node was always the one who has one or more values as its lower levels like this:
    A. 10
        A1.  100
        A2.  101
        A3.  102
             A3.1.  1021
    B. 11
    I this case I thought , for example, 101 was a single value but not a hierarchy node so I must find it in the single values list in the selection window, however, 102 can be both and must appear in both lists, is it true?
    Thanks in advanced

    In BW, hierarchy node with more information compare to the single value. for example, it always carries its father node information, which it belongs to. and some time information if it is time-dependent.
    So, when you using hierarchy node, it means at least 2 information: value and "position" (who is its father node)
    That's the reason why you see the hierarchy tree when choosing the node.
    If you want to expand the hierarchy to the certain level, you can setting in the property. Another choice is restrict in the query designer.

  • How to filter hierarchy node in BEX query designer

    Dear experts
    We are working on FI balance sheet with hierarchy infoobject 0GLACCEXT. Example of our balance sheet is as follow:
    Parent Node A = 20
         Sub-parent Node A1 = 10
             Leaf A11 = 5
                 Leaf A12 = 5
    Parent Node B = 20
         Sub-parent Node B1 = 10
                   Leaf B11 = 5
                   Leaf B12 = 5
    We require only:
        Sub-parent Node A1 = 10
        Leaf B12 = 5
    So I filter those out in BEX restriction;  however, after we examine the report in tcode RSRT, "Sub-parent Node A1" is not shown in BEX Report, and the result is as follow:
    Parent Node B = 5
         Sub-parent Node B1 = 5
                 Leaf B12 = 5
    Are there solutions for us to show merely A1 and B12 ?

    Hi Chu
    Try the following steps.
    Initial Output
    In this example I will restrict the query for only displaying Node 8603 and leaf 9000
    Proceed to restrict the Characteristic. Please be aware of the difference between hierarchy nodes and leaf characteristic values. Also set the Hierarchy display properties to expand up to level 1.
    Execute the query again:
    Please be aware that users will still be able to expand node 8603 and see the lower level nodes/leaf. In order to restrict users from doing this set up users authorizations.
    Regards,
    Carlos

  • 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

  • Drilldown to hierarchy nodes in VC..

    Hi..
    I want drilldown functionality in VC..
    1. my Query has a hierarchy
    2. my VC application has a table attached to this query.
    3. In Output the hierarchy nodes are displayed
    4. i ve taken a button Drilldown on my table
    5. on selection of a node and onclick of button all the hierarchy nodes get expanded(drilled down)
    Problem : i do not want all the nodes to get drilled down..only the selected node should get drilled..
    Plz help me out for the same...
    Thanks in advance..
    Bhavna.

    Hi,
    Just check out in hierarchy attribute setting... what is the start node for the drill down..
    Regards,
    Viren.

  • Hierarchy Node Variable search (find) option not working

    Hi Experts - I have created a hierarchy node varibale on a fixed hierarchy. When user run the report and click on hierarchy node variable selection option , A new window will pop up which has all the nodes.
    As the list is quite big and has many levels , On the same pop up , we have find option , when we enter any node in the find box , its always give a ABAP Dump , It never works for me...
    Is node find/search in not working in Bi 7.0 .
    Thanks
    R

    Hi Rohan,
    We can restrict the hierchey level at property of of the hiearchey enabled characteristic.
    Hope this hels...let me know if u require any further info on this..
    Best Regards,
    Maruthi

  • How to pass a hierarchy node variable value over OpenDocument?

    Hello,
    I have been unable to link to an instance with matching parameters with opendocument with hierarchy node variables.
    Has anyone attempted this or been successful?
    Please reference this post I had in the Web Intelligence forum.  sInstance=Param not working for sap bw query based reports (FWM 02020)
    Here's some background information
    We've created 2 new crystal reports based of sap queries.
    Report 1, single prompt, no hierarchy.
    Result : Can link to specific instance with matching parameters. Great!
    Report 2, single prompt, hierarchy based.
    Result: Cannot link to specific instance with matching parameters
    Parameter list for report 2
    [!V000001} : Cost Center/Gr{oup (Multiple) = {0COSTCENTER XXXXXXXX.BGT3}.{XXXXXXXXX.BGT3 0HIER_NODE} - XXX, XXX & XXX
    However when I go into the history and look at the successful instance parameters used, it seems to be picking up an extra parameter ( my guess is node)
    XXX, XXX & XXX; {0COSTCENTER XXXXXXXX.BGT3}.{XXXXXXXXX.BGT3 0HIER_NODE} - XXX, XXX & XXX
    We have attempted to use the entire string, the first portion, second portion, and just the technical response. No luck.
    Any help or pointers would be appreciated!
    Nick

    Hello  Ingo,
    I'll explain the situation more clearly,
    Report 2, single prompt, hierarchy based.
    Result: Cannot link to specific instance with matching parameters with a response from the Bus Objects server
    An error has occurred: The object with ID -1 does not exist in the CMS or you don't have the right to access it (FWM 02020)
    We have 1 parameter for report 2
    {!V000001} : Cost Center/Group (Multiple)
    We selected a single value:
    {0COSTCENTER XXXXXXXX.BGT3}.{XXXXXXXXX.BGT3 0HIER_NODE} - XXX, XXX & XXX
    (The XXX, XXX, & XXX is the description)
    We ran a successful instance.
    However when I go into the history and look at the successful instance parameters used it displays the following: 
    XXX, XXX & XXX; {0COSTCENTER XXXXXXXX.BGT3}.{XXXXXXXXX.BGT3 0HIER_NODE} - XXX, XXX & XXX
    An extra description seems to appear (The first XXX, XXX & XXX;) Our original selection was only {0COSTCENTER   XXXXXXXX.BGT3}.{XXXXXXXXX.BGT3 0HIER_NODE} - XXX, XXX & XXX
    We attempted to build variations of the open document strings
    1. We tried the entire parameter response,
    XXX, XXX & XXX; {0COSTCENTER XXXXXXXX.BGT3}.{XXXXXXXXX.BGT3 0HIER_NODE} - XXX, XXX & XXX
    2. The first description that was not part of the original selection,
    XXX, XXX & XXX
    3. The technical name and description
    {0COSTCENTER XXXXXXXX.BGT3}.{XXXXXXXXX.BGT3 0HIER_NODE} - XXX, XXX & XXX
    4. The technical name
    {0COSTCENTER XXXXXXXX.BGT3}.{XXXXXXXXX.BGT3 0HIER_NODE}
    Please let me know if you need more details.
    Regards,
    Nick

Maybe you are looking for