Query to derive number of children "folders/nodes" and children "line items" from a numbering sequence

I am writing a query to determine some information from a work breakdown numbering structure (single column) and it is simple enough to describe, just not sure how to do it in code.  I am trying to determine for the parent items, how many children items
that parent has and how many children folders are under that parent (think of something like a folder/file structure).  The numbering structure looks like this:
1       
1.1     
1.2     
1.2.1   
1.2.2   
1.2.3   
1.2.3.1 
1.2.3.2 
1.2.3.3 
1.2.4   
1.2.5   
1.2.5.1 
1.2.5.2 
1.3     
I would like my query to return this information:
WBS    ChildFolders ChildLineItems
1.1               0                      0
1.2               2                      8
1.3               0                      0
Hope that makes sense!  

I almost have this working in the following query in at least I figure out a way to tell how which ones were the folders and which were the line items with this query (sorry I have different WBS numbers than my example above:
declare @wbs table (wbs varchar(max))
insert @wbs select
'1.1'     as wbs union all select
'1.2'     union all select
'1.2.1'   union all select
'1.2.2'   union all select
'1.2.3'   union all select
'1.3'     union all select
'1.4'     union all select
'1.4.1'   union all select
'1.4.1.1' union all select
'1.4.1.2' union all select
'1.4.2'   union all select
'1.5.1' 
select 
x.wbs
, CASE count(x.wbs) WHEN 1 THEN 'LineItem' ELSE 'Folder/Has Children' END as Description
from
@wbs x
,(select
from @wbs w) as data
where
data.wbs like x.wbs + '%'
group by
x.wbs
This give me these results:
WBS Description
1.1 LineItem
1.2 Folder/Has Children
1.2.1 LineItem
1.2.2 LineItem
1.2.3 LineItem
1.3 LineItem
1.4 Folder/Has Children
1.4.1 Folder/Has Children
1.4.1.1 LineItem
1.4.1.2 LineItem
1.4.2 LineItem
1.5.1 LineItem
I would just like to add the columns with the counts of ChildFolders and ChildLineItems like my example above.
For example the results for 1.4 would look like this:
WBS Description
ChildFolders ChildLineItems
1.4 Folder/Has Children
1 3

Similar Messages

  • Derivation of Profit Centers in case of bank and Cash line items

    We are in the process of configuring the Profit Center Accounting functionality. We are in ECC 6.0 but have not migrated to New G/L.
    We understand that Profit center needs to be derived for each of the items for which it does not flow online in realtime. As regards Bank and Cash Line Items, we are not able to understand how Profit Center Derivation will happen.
    We have posted an FI payment document using Tcode F110 and further to which we executed F.5D and 1KEK. Further to this, we have checked the Profit Center Total records report (2KEE). It updates the vendor line items. But it does not reflect the Bank line item. Unless this happens, we understand that our Profit Center wise Trial Balance will not tally.
    Kindly let us know how bank and Cash line items will update in PCA. In our view, it should derive the Profit center from the offsetting entry in the vendor invoice. Pl. correct me if I am wrong.
    Pl. help.
    Venkat Iyer

    Hi Venkat,
    You may define a derivation rule in 3KEH
    Regarda
    Sachin

  • Abap query to select a line item # from bseg on basis of following pattern:

    Hello,
    I want to retrieve the line item # from bseg which has the following pattern,
    account type = S
    AND
    gl account starting from 135***** , 136***** , 137*****
    , 138***** , 139*****
    hope i am comprehendable. How do i go on writing the query,
    Thanks..
    Shehryar

    Hi Shehryar,
    This will fetch records with GL A/C starting with <b>13</b> only , if you want 14 and others also write sepearate conditions using <b>LIKE</b> statements.
    REPORT zztest.
    DATA : itab TYPE STANDARD TABLE OF bseg WITH HEADER LINE.
    SELECT * FROM bseg INTO TABLE itab WHERE <b>koart = 'S'
    AND
    hkont LIKE '13%'</b>.
    This will take a lot of DB time for fetching the records, try to include Key Fields(BUKRS and GJAHR .. if possible others).
    Regards,
    Arun Sambargi.
    Regards

  • GR Doc# and GR Line Item Number

    Hi All,
    We have custom defined infocube actually WM-stocks.Now our requirement is to add GR Number and GR line Item Number. can be these be added to Infocube or should we go for ODS? any help from experts?
    Data has been loaded from generic datasource which is based on LQUA table.
    regards

    Hi,
    We implemented just the opposite:
    A cube for line items, an ODS for header data which didn't went to the cube (I mean those data that cannot be calculated by summing up item data).
    If we need summary data from ODS, we use RRI.
    Everything depends on a level of details you need. In our case we needed analysis on item data.
    Best regards,
    Eugene
    Message was edited by: Eugene Khusainov

  • I've changed my account's country, adress, and phone number because I've moved and my purchased apps (from previous country) does not appear anymore, how do I fix it?

    I've changed my account's country, address, and phone number because I've moved and my purchased apps (from previous country) does not appear anymore, how do I fix it?

    That is the expected behavior. You will also no longer be alerted to any updates for that content.
    If any of the content is sold in the new country's store and you find out through the grapevine about an update, you can update the content for free, but you will have to go through the steps for buying the update as a new purchase. Then the store will notice in the final steps that you own this content and update for free. It is the end of the road for any content from the previous country that is not sold in the current country's store. You will not be able to update the content in the new store.

  • Cheque Number in Vendor and GL Line iTem Display

    Hi
    How can we get to display the Cheque Number in T Codes FBL1N and FBL5N
    Samir

    Hi
    Please follow the paths
    GL Accounts:
    IMG ==> General Leder Accounting ==> Master Data ==> GL Accounts ==> Line Items ==> Define Special Fields for Line Item Disply
    Enter Table PAYR
    Field Name CHECF
    Vendor Accounts
    IMG ==> Accounts Receivable and Accounts Payable ==> Vendor Accounts ==> Line Items ==> Display Line items ==> Define Additional Fields for Line Item Display
    Enter Table PAYR
    Field Name CHECF
    After adding this, when you run FBL1N and FBL3N you can see the cheque number against payment documents.
    Thanks & Best Regards
    Sanil K Bhandari

  • Query on setting of ORACLE_HOME in RAC node and more errors

    i m following oracle docs for install Oracle 10g R2 RAC on RHEL 5.
    i am able to get through most of the part but one minor thing is still bugging me.
    Enter commands similar to the following to set the ORACLE_BASE and
    ORACLE_HOME environment variable in preparation for the Oracle Clusterware
    installation:
    ■ Bourne, Bash, or Korn shell:
    $ ORACLE_BASE=/u01/app/oracle
    $ ORACLE_HOME=/u01/crs/oracle/product/10/app
    $ export ORACLE_BASE
    $ export ORACLE_HOMEthe above extract from the docs (B14203-09) says ORACLE_HOME should be set to the dir where clusterware is installed.
    my query is do we change this ORACLE_HOME to '/u01/app/oracle/product/10/db_1' when we install the oracle database after we finish installing the clusterware.
    Further, permissions for the /u01/crs directory should be root:oinstall and 775 during the installation of the clusterware and changed to 644 after installation of clusterware. is that correct? is it 644 or 640? does it need read access for every one?
    Edited by: iinfi on Jul 5, 2009 1:42 AM
    Edited by: iinfi on Jul 5, 2009 12:20 PM

    i initially thought not setting the oracle_home to the crs directory was the cause of the error message
    [root@node1 ~]# /ora/app/oracle/product/10.2.0/crs/root.sh
    WARNING: directory '/ora/app/oracle/product/10.2.0' is not owned by root
    WARNING: directory '/ora/app/oracle/product' is not owned by root
    WARNING: directory '/ora/app/oracle' is not owned by root
    WARNING: directory '/ora/app' is not owned by root
    WARNING: directory '/ora' is not owned by root
    Checking to see if Oracle CRS stack is already configured
    Setting the permissions on OCR backup directory
    Setting up NS directories
    Failed to upgrade Oracle Cluster Registry configurationthe crs directory is owned by root:oinstall with permissions set to 775. CRS and voting disks are raw devices set on my RHEL 5.3 with openfiler as storage (iSCSI targets)
    [root@node1 node1]# cat /ora/app/oracle/product/10.2.0/crs/log/node1/client/ocrconfig_9680.log
    Oracle Database 10g CRS Release 10.2.0.1.0 Production Copyright 1996, 2005 Oracle.  All rights reserved.
    2009-07-05 02:03:01.250: [ OCRCONF][14166224]ocrconfig starts...
    2009-07-05 02:03:01.253: [ OCRCONF][14166224]Upgrading OCR data
    2009-07-05 02:03:01.300: [ OCRCONF][14166224]OCR already in current version.
    2009-07-05 02:03:01.363: [ OCRCONF][14166224]Failed to call clsssinit (21)
    2009-07-05 02:03:01.363: [ OCRCONF][14166224]Failed to make a backup copy of OCR
    2009-07-05 02:03:01.363: [ OCRCONF][14166224]Exiting [status=failed]...can someone please throw some light as to what i am missing here.
    thanks

  • Account Number of the Alternative Payee and Pay all items separately

    Hi:
    I have create one vendor (FK01)  with fill the Account Number of the Alternative Payee (LFA1-LNRZA) and Indicator: Pay all items separately  (LFB1-XPORE).
    But when I go to F110 to make the payment it group payments in just a unique payment.
    How can I pay all item separately when it goes to an alternative payee account?
    Thanks!

    Hi:
    The problem comes in some vendors, we have some vendors with have as an alternative payee the same vendor but with different adress.
    Those alternative vendors just have in master data the information reference to adress but they dont have filled information about payee.
    So, when we make an automatic payee with F110 tcode it groups all the items wrongly in the same invoice wich is no correct because sometimes they develop to different invoices.

  • Names of folders disapear and black lines

    Recently disappears the names of my folders in my desk and it appears a small 3 cm black horizontal line ,too.I restarted my Macbook and it was no more.What is happening it is a type of virus or a problem with the screen.??????
    Thanks a lot.
    Bye.

    First try magic Resetting your Mac's PRAM and NVRAM
    and Resetting MacBook System Management Controller (SMC)
    Than in Applications - Utilities - Disc Utility,Repair Disc Permissions.

  • Missing folders, albums and images when Migrating from iPhoto to Aperture

    I have 3,333 image in iPhoto (v.7.1.3). I'd like to import the entire library into Aperture (v.2.1) and use that primarily to edit and organize the images from here on out. Problem is, when I try to import the iPhoto library from Aperture, it only imports half of the images (1,553 images). I tried deleting the Aperture library and re-importing everything but had the same result. Any suggestions would be appreciated -- I'm eager to get started in Aperture after years of iPhoto.

    Hope we get an answer - I'm in the same situation as you, though I just went from iPhoto to A2.x on an older G5 tower. I've been debating whether to take the time to go through them, reorganize "better" than they were under iPhoto or wait for a more elegant solution...
    KWO

  • Is it possible to use a content query web part to pull and display rows/items from an Excel spreadsheet saved in a SP library?

    I have an Excel spreadsheet that I want to upload to an SP library. Is it possible to display these items (in a non-excel format, more like an SP list format) in a web part? 

    Have you tried using the Excel web part
    Display Excel content in an Excel Web Access Web Part

  • PO Number and Line Item Number for Invoice Plan Number

    Hi Experts,
    Can somebody please guide me how to fetch the PO Number and respective PO Line Item Number for an Invoice Plan (FPLNR).
    In FPLA Table, PO number is available but line item number is not available.  If a PO is having multiple line items, different line items will have different Invoice Plan numbers.
    Thanks in Advance.
    Radha Krishna Madineedi

    Hi Ramesh,
    I have got the answer after posting this thread.  We can get the PO Number and the Line Item from EKPO Table itself by passing the FPLNR.
    Anyway,  thanks for your reply.
    Regards
    Radha Krishna.

  • RSBBS Jump: AR Line Item Query to R3 Customer Line Item Display

    I am attempting to create a 'Jump Target' from the 0FIAR_C03 AR Line Item Infocube to the R3 FBL5N Customer Line Item Display transaction.
    The query that the jump is to be performed from an Aging query.
    The user will be running this query for all transactions posted up to and including the end of the previous calendar month. The posting date is provided by the user when submitting the query (via variable 0P_KEYD2). The aging report works just fine.
    Where I'm having the problem is when the user wishes to jump to the R3 transaction FBL5N to display the Customer Line Items. The user wants the 'Line Item Selection' in R3 to inlcude 'Open Items' (this button should be selected -- it is the default setting) where 'Open at Key Date' is to be derived from the query result in the Excel workbook.
    I have created the RSBBS Sender/Receiver Assignment so that it goes and retrieves the line items from R3 for the correct customer. However, I have not been able to figure out how to populate the 'Open at Key Date' with the end Posting Date (OPSTNG_DATE) from the query.
    I've tried every combination I can imagine in the 'Assignment Details' section in RSBBS, but so far I have not been able to make it work.
    Has anyone else out there tried this?
    If you have, were you able to populate the 'Open at Key Date' (ALLGSTID) field in the R3 FBL5N transaction? If you were able to do this, how did you do it?
    All ideas appreciated . . .

    I'm still hoping that someone can help with this issue.
    Here's a repeat of the original question:
    I am attempting to create a 'Jump Target' from the 0FIAR_C03 AR Line Item Infocube to the R3 FBL5N Customer Line Item Display transaction.
    The query that the jump is to be performed from an Aging query.
    The user will be running this query for all transactions posted up to and including the end of the previous calendar month. The posting date is provided by the user when submitting the query (via variable 0P_KEYD2). The aging report works just fine.
    Where I'm having the problem is when the user wishes to jump to the R3 transaction FBL5N to display the Customer Line Items. The user wants the 'Line Item Selection' in R3 to inlcude 'Open Items' (this button should be selected -- it is the default setting) where 'Open at Key Date' is to be derived from the query result in the Excel workbook.
    I have created the RSBBS Sender/Receiver Assignment so that it goes and retrieves the line items from R3 for the correct customer. However, I have not been able to figure out how to populate the 'Open at Key Date' with the end Posting Date (OPSTNG_DATE) from the query.
    I've tried every combination I can imagine in the 'Assignment Details' section in RSBBS, but so far I have not been able to make it work.
    Has anyone else out there tried this?
    If you have, were you able to populate the 'Open at Key Date' (ALLGSTID) field in the R3 FBL5N transaction? If you were able to do this, how did you do it?
    All ideas appreciated . . .

  • Please let me know how to Count Number of completed line items in past 6 mo

    How to Count Number of completed line items in past 6 months / 12 months ?
    Hi,
    I am trying to count "Number of Completed Line Items in Purchase Order Document" for my Key Figure ZPO_CNT.
    Purchase Order document = ZEBELN
    Line Item = ZEBELP.
    I need to find and count if the Line Item has been received in the past 6 months from today and similarly in the past 12 months.
    I have "Delivery Completed" field, ELIKZ.
    So, based on this would I be able to calculate it in Query Designer?
    If so, Please let me know how
    Krishna

    Hi Experts,
    I dont have a defined Restricted key figure yet.
    I have populated 0COMPL_DEL(Delivery Completed Indicator)  and 0EBELN (Purchasing Document Number) and 0EBELP (Line Item Number in Purchasing Document) .
    This is what I think how I need to calculate:
    Number of completed line items in past 6 months:
    If  Delilvery Completed Indicator (0COMPL_DEL) = x, calculate No. of Line Items (ZPO_CNT) from 0CALDAY to 6 months
    and
    Number of completed line items in past 12 months:
    If  Delilvery Completed Indicator (0COMPL_DEL) = x, calculate No. of Line Items (ZPO_CNT) from 0CALDAY to 12 months
    Please let me know if the logic is correct. If so, how I can create this in report

  • Line item confirmation and goods reciept number of a shopping cart

    Hi All ,
    I am waiting for any response from u guys to my below post ....
    I  have developed an end to end report in SRM which gives us an end to end report of a shopping cart .
    I have got the Shopping Cart details using FM : BBP_PD_SC_GETDETAIL
    for each item of the shopping cart in the table E_ITEM , getting the Po number for it from E_ITEM- BE_OBJECT_ID
    I called FM BBP_BE_PO_GETHISTORY to get the Confirmation and Invoice number from E_HEADER_REL of BBP_BE_PO_GETHISTORY.
    But this function module gives me the confirmation and invoice number of a particular purchase order and
    I am stuck here as I need to find out the confirmation and invoice number of a line item and I am not finding a link between them .
    I tried using FM BBP_PD_PO_GETDETAIL ,
    BBP_PD_PO_GETLIST
    BBP_PD_PO_DOC_FLOW and other function modules also , however they give me the confirmation and invoices o a particular PO but I am not able further drill down to find confirmation and invoivce of a particular line item of a shopping cart …..
    Please let me know if there is a way to find this out ????
    Has anybody have an idea to find this out ????
    Useful answers would be rewarded .
    Regards,
    Prabhu

    Hi All ,
    I was able to get a link using the function module  BBP_PD_SC_GETDETAIL . in the tables E_item  has fields BE_OBJ_ITEM  and the BE_OBJ_ITEM which give the po number and po line item number of each line item .
    then i used BBP_BE_PO_GETHISTORY Fm to get the history of the po and read the line item history based on the BE_OBJ_ITEM  no .
    Thanks to all .
    Prabhu

Maybe you are looking for

  • How do I create a new ssh SMF service?

    Hello. I looked all over before posting this...I just completed four Solaris 10 builds using OPSWARE. All four builds are on V120's. I had two Solaris 10 with older hardware release 3/05 I belive, those were fine, but the two with release 1/06 did no

  • IMac does not detect correct resolution of 2nd monitor

    I am attempting to use my 42" LG HDTV as a 2nd monitor for my iMac. The native resolution for the LG is 1920x1080 but the iMac only allows me to select up to 1600x1200. It seems to think that the LG is a smaller screen than the iMac as well and my im

  • Replacing approver

    Hello people, I'm facing a problem when the final user A is creating a shoping car, and changes the approver. This user A has the role to create the shooping car only. But he can change the approver pointing to a user B, that has no role of approver.

  • Create a delivery note after an advance invoice is paid

    Suppose that the use of an advance invoice is that you deliver items to your client only after your client has paid the price for these items in advance. Now assume the following situation: 1. You book an advance invoice. 2. You wait until the amount

  • Perspective Grid: How do I draw a cube showing only its TOP and its FRONT?

    Can I create this with Illustrator's Perspective Grid? the 1-, 2-, and 3-point perspectives don't seem to be what I need...