Counting how many number of elements in a XML

Hi all,<br />
        I am having a requirement in ABAP-IXML ie., i need to find how many times a same element name(ComponentUsage) gets repeat in an xml.<br />
here is the xml,<br />
<br />
&lt;Component mmRelease="6.30" mmVersion="2.0" mmTimestamp="1180099591892" name="Comp_three" package="sap.com" masterLanguage="en"&gt;<br />
<br />
&lt;Component.ComponentUsages&gt;<br />
&lt;<u><b>ComponentUsage</b></u> lifecycleControl="createOnDemand" name="comp1"&gt;<br />
&lt;ComponentUsage.ComponentControllerUsages&gt;<br />
&lt;ComponentControllerUsage name="Configuration"&gt;<br />
&lt;/ComponentControllerUsage&gt;<br />
&lt;/ComponentUsage.ComponentControllerUsages&gt;<br />
&lt;ComponentUsage.UsedComponent&gt;<br />
&lt;Core.Reference package="sap.com" name="Comp_twoInterface" type="ComponentInterfaceImplementation"/&gt;<br />
&lt;/ComponentUsage.UsedComponent&gt;<br />
&lt;/ComponentUsage&gt;<br />
&lt;/Component.ComponentUsages&gt;<br />
<br />
&lt;Component.ComponentUsages&gt;<br />
&lt;<u><b>ComponentUsage</b></u> lifecycleControl="createOnDemand" name="comp2"&gt;<br />
&lt;ComponentUsage.ComponentControllerUsages&gt;<br />
&lt;ComponentControllerUsage name="Configuration"&gt;<br />
&lt;/ComponentControllerUsage&gt;<br />
&lt;/ComponentUsage.ComponentControllerUsages&gt;<br />
&lt;ComponentUsage.UsedComponent&gt;<br />
&lt;Core.Reference package="sap.com" name="Comp_twoInterface" type="ComponentInterfaceImplementation"/&gt;<br />
&lt;/ComponentUsage.UsedComponent&gt;<br />
&lt;/ComponentUsage&gt;<br />
&lt;/Component.ComponentUsages&gt;<br />
&lt;/Component&gt;<br />
<br />
Here as the xml is short so i manually knows tat the element "ComponentUsage" are used 2 times, but suppose if i use a big xml and the component usage element is used "N" number of times then how can i count mannually....... so is there any method or code to find how many times does "ComponentUsage" element present in an XML.<br />
<br />
Thanks in advance,<br />
Vishnu<br />

First check this Blog
/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
you can check this thread
Upload XML to internal table and vice versa in SAP 4.6C

Similar Messages

  • Count how many time we have each element

    I can't count how many the same element is on my array, I have an array [21, 12, 4, 21, 21, 4]
    I expect to have something like this:
    number exist number
    21 3
    12 1
    4 1
    below is the code
    System.out.printf("%10s,%10s \n", "number exist", "number");
              for(i = 0; i < list.size(); i++){
                   for(int j = 0; j < list.size(); j++){
                        if (list.get(i) == list.get(j))
                             v++;
              System.out.printf("%10s,%10s \n",v,list.get(i));     
    Edited by: ronisto on 11-Mar-2008 1:34 PM
    Edited by: ronisto on 11-Mar-2008 1:39 PM

    good actually I 'm using a List, I could'nt find where is wrong, I can print for the first one, but if I try to use the for it' s not working...look the code below with a list like this [5 , 1, 7, 1, 1, 5]
              System.out.printf("%10s,%10s \n", "Column1", "Column2");
                   for(j = 0; j < list.size(); j++){
                             if (list.get(j) == list.get(0))
                                  v++;
                   System.out.printf("%10s,%10s \n",v,list.get(0));
    result give me:
    Column1 Column1
    3 1
    til here is good but when I try to print samething for all elements of my list it doesn't work
    System.out.printf("%10s,%10s \n", "number exist", "number");
                   for (i = 0; i < list.size(); i++){
                        for(j = 0; j < list.size(); j++){
                             if (list.get(j) == list.get(i))
                                  v++;
                   System.out.printf("%10s,%10s \n",v,list.get(i));
    Edited by: ronisto on 11-Mar-2008 6:04 PM

  • I see people from different ages at my work and every month I need to count how many people from each age I've seen that month. How can I do to give the entries to numbers in a single cell and make numbers count them for me?

    I see people from different ages at my work and every month I need to count how many people from each age I've seen that month. How can I do to give the entries to numbers in a single cell and make numbers count them for me? The final result would be a spreadsheet telling there were 8 people from 20 to 39 years old, 14 peolple from 40 to 59 and so on...

    jpqcampos wrote:
    This appears to be an 'input form' using 'Radio Buttons' to select the category. Neither of these features are supported in Numbers '09.
    You can input the data on one table and summarize it on a second table, but the input table will continue to hold data for each event.
    And by using the Reorganize button, you can hide all but two rows of that table to approximate the appearance and performance of an input form.
    Here are the two tables, Data on the left and Summary on the right. Notes below.
    The grey-filled columns in both tables are 'working' columns, and may be hidden (as shown in the image below).
    Data table:
    D1 contains the word "TRUE" (in capital letters). (This row is always shown.)
    D2 is empty, or may contain any value except "TRUE" (This row is always hidden under the Reorganize rule.)The rest of Row 2 of this table requires the data shown: a number outside the range to be counted (999), and two checkboxes, both checked.
    D3 (and filled down the rest of column D):   =AND(OR(B2,C2),NOT(OR(B3,C3)))
    The formula returns TRUE only for the first unused row in the table (ie. the first row for which neither checkbox has been checked)
    Summary table:
    Column A contains labels for the age ranges to be counted.
    Column B contains the same information in the form necessary for the formulas in columns C and D. They need a numeric value, and that value must be the largest acceptable value in the range to be counted.
    C2 (and filled right to column D, then both filled down to row 5):
        =COUNTIFS(Data :: $A,"<="&$B,Data :: B,TRUE)-SUM(C$1:C1)
    Two changes from the previous example:
    COUNTIFS is used to separate the Native and Foreign counts as well as the age range to be counted.
    The amount subtracted from each result is the SUM of the earlier results, and includes the text value in the first cell of the column (which is interpreted by SUM as a zero).
    See note below regarding my earlier formula.
    When the greyed columns are hidden and the checkbox in the Reorganize pane is checked, the two tables will appear as shown below:
    Close the reorganize pane, and the 'data entry form' is ready to use.
    To use, enter the age first, then check one of the boxes.
    As soon as one box is checked, the row will be hidden, and the next (unused) row will be shown.
    Regards,
    Barry
    Note regarding formula in my earlier post:
    The earlier formula will give erroneous results as it subtracts only the count directly above it from its count of persons in the age range 0-n.
    In E2 of that table, replace "-E1" with "-SUM(E1:E$1)
    Fill down to E8.
    Ignore the instructions (in that post) following "Fill down to E8."
    B

  • Counting how many times my app has been opened

    I want to be able to count how many times a user has opened my application, and so every time the application launches, this number is added by one.
    Does anyone know how I store a long-time variable like this that will still need to be available across different runs of the application? I imagine this value would be stored in the application's preference file in Library, but I don't know how to do this.
    Can any of you please lend me some advice/code to achieve this (I am using Objective-C)?
    Thanks in advance,
    Ricky.

    Hi.
    It has been a while - but I finally got around to slapping some code together. I have successfully created and retrieved the value from the preference file, but for some reason, adding 1 to my value each run is not working. It only adds by one after each BUILD. So I have to rebuild it every time I want it to increment. See my code below;
    [NSUserDefaults init];
    int numberOfTimes;
    numberOfTimes = [[NSUserDefaults standardUserDefaults] integerForKey:@"used"];
    numberOfTimes = numberOfTimes++; //It is that that is not working.
    [[NSUserDefaults standardUserDefaults] setInteger:numberOfTimes forKey:@"used"];
    NSLog (@"%d", [[NSUserDefaults standardUserDefaults] integerForKey:@"used"]);
    I can't seem to stop anything wrong, but then again it is late.
    Do any of you see any errors here?
    Thanks,
    Ricky.

  • How many number of times a particular report was executed

    Hi..My requirement is to find how many number of times a report/tcode was executed in a particular period of time.I tried using STAD,STAT AND ST03 ..but i am not able to find how many number of times the particular report was executed ..is there any other tcode or table or FM ..that would solve this problem..its bti urgent..wud reward points for all useful answers could u let me know under what name or field int eh out put this particular info that i am looking for wud be displayed?

    Hi,
    The following code i found from this forum, may this will help you.
    * internal tables for use counter
    data: begin of list occurs 5.
            include structure sapwlserv.
    data: end of list.
    data: begin of applicat occurs 0.
            include structure sapwlustcx.
    data: end of applicat.
    data: begin of applica_ occurs 0.
            include structure sapwlustcx.
    data: end of applica_.
    data: begin of applicau occurs 0,
            entry_id like sapwlustcx-entry_id,
            account  like sapwlustcx-account,
            count    like sapwlustcx-count,
        : end of applicau.
    data: wa_applicau like applicau.
    *&      Form  MONI
    form moni.
      data: l_host like  sapwlserv-hostshort.
      m_start = p_usedt.
    *** get server
      call function 'SAPWL_SERVLIST_GET_LIST'
           tables
                list = list.
      do.
        loop at list.
    *** loop on server
          check not list-instshort is initial.
          l_host = list-instshort.
    *** get statistics per month and server
          perform workload using m_start l_host.
        endloop.
        add 31 to m_start.
        if m_start > sy-datum.
          exit.
        endif.
      enddo.
      sort applica_ by entry_id.
      sort applicau by entry_id count descending.
    endform.                               " MONI
    *&      Form  WORKLOAD
    form workload using    p_start like sy-datum
                             p_host  like  sapwlserv-hostshort.
      refresh: applica_.
    *** read application statistic from MONI
      call function 'SAPWL_WORKLOAD_GET_STATISTIC'
           exporting
                periodtype                 = 'M'
                hostid                     = p_host
                startdate                  = p_start
                only_application_statistic = 'X'
           tables
                application_statistic      = applica_
           exceptions
                unknown_periodtype         = 1
                no_data_found              = 2
                others                     = 3.
      sort applica_ by entry_id account.
      loop at applica_  where entry_id(1) ge 'Y'.             "#EC PORTABLE
        clear wa_applicau-entry_id.
        wa_applicau-entry_id(25) = applica_-entry_id.
        wa_applicau-account      = applica_-account.
        wa_applicau-count        = applica_-count.
        collect wa_applicau into applicau.
      endloop.
      sort applicau by entry_id count descending.
      applica_-ttype    = space.
      applica_-account  = space.
      modify applica_ transporting ttype account
             where ttype ne space.
    *** collect only enhancements statistic
      if p_temp = 'X'.
        loop at applica_.
          applica_-entry_id+25(48) = space.
          collect applica_ into applicat.
        endloop.
      else.
        loop at applica_ where entry_id(1) ge 'Y'.            "#EC PORTABLE
          applica_-entry_id+25(48) = space.
          collect applica_ into applicat.
        endloop.
      endif.
    endform.                               " WORKLOAD
    aRs
    Points are always welcome

  • Hey! On excel I want to count how many time a text come back in the spreadshit (sum) thx, hey! On excel I want to count how many time a text come back in the spreadshit (sum) thx

    Excel:
    line of cellule with 3 different text. I want to count have many time a text come in the line... Thx for helping me, it is for my job!!

    Hopefully I am understanding your question.
    A typical way to count how many times a word appears in a line of text in a cell is to substitute spaces for the word, one less space than the length of the word. Example:
    A1 has the string "brown red brown green"
    A2 =LEN(A1) - LEN(SUBSTITUTE(A1,"brown","    "))  
    "brown" has five letters so there are four spaces in the substitution text)
    If you want to do several cells at once, counting the total number of times the word appears, concatenate the cells with a space between them
    A1 and A2 have text in them
    A3 =LEN(A1&" "&A2) - LEN(SUBSTITUTE(A1&" "&A2,"brown","    "))

  • How to count how many times the caller calls by using UCCX script?

    Hi there,
    My customer wants to do a few changes for their script as below:
    At the beginning of the script they are planning to add a new menu item, it will announce their new privacy policies and to continue the user must press the number one to continue to the Welcome.  If they do not press 1 then the message should repeat itself and if they again do not press 1 they should be transferred over to a live operator who will explain things and then be able to transfer them back to the message so that they can press 1 and continue.
    I modified their script as attached file, but i don't know how to count how many times the caller calls in "Get Reporting Statistic".
    Any helps would be appreciated.
    Thanks.

    Hi Aaron,
    At beginning, i want to use a variable to get number of mistake for the same caller, then we will send the call to right place to fulfill the customers' needs. 
    Do you have any suggestion for the new posted script?
    Thanks.

  • How do you count how many times a if/when/for statement runs?

    So this new program I'm trying to write is a changemaker (in euros for some reason). You enter a price of a product, amount paid, and it computes how much change you should get back in the form
    [number] x 2-euro
    [number] x euro
    [number] x 20-cent
    etc
    Where the number is the number of that kind of coin they should get back.
    Right now, I have it so that you enter price, and amount paid, and then I have a series of while statements that go like..
    while (surplus > 2.00);
    while (surplus > 1.00);
    etc. If the surplus > 2, I want to add 1 2-euro coin to the count, subtract 2, and then recheck the amount and either add another 2-euro or go onto the next coin. Only thing is, I don't know how to count how many times a while statement ran until it was false. Or I could be looking at this the wrong way entirely. What's the best way to go about a program like this?

    Well I finally figured it out with lots of help from other students in the class. It was much easier than it appeared to be. Thanks for the hints everyone (especially joker for doing the coding for it) wow :D much appreciated ^^
    Heres the code that I came up with and it works matches the assignment's example:
    import java.util.* ;
    public class ChangeMaker {
         private static int changeA [] = new int [7] ;
         private static float changeVar[] = new float [7] ;
         private static int changeVarNumb[] = new int [7] ;
         private static String changeNames[] = new String [7] ;
         // initialize Scanner
         private static Float getInput (String prompt){
              System.out.print (prompt.concat(" ")) ;
              Scanner sc1 = new Scanner (System.in) ;
              return (sc1.nextFloat ()) ;
         // put the change variables and change names into arrays
         private static void moneyArray (){
              changeVar[0] = (float) 2.0 ;
              changeVar[1] = (float) 1.00 ;
              changeVar[2] = (float) 0.20 ;
              changeVar[3] = (float) 0.10 ;
              changeVar[4] = (float) 0.05 ;
              changeVar[5] = (float) 0.02 ;
              changeVar[6] = (float) 0.01 ;
              changeVarNumb[0] = 2 ;
              changeVarNumb[1] = 1 ;
              changeVarNumb[2] = 20 ;
              changeVarNumb[3] = 10 ;
              changeVarNumb[4] = 5 ;
              changeVarNumb[5] = 2 ;
              changeVarNumb[6] = 1 ;
              changeNames[0] = (String) "Euro" ;
              changeNames[1] = (String) "Euro" ;
              changeNames[2] = (String) "Cent" ;
              changeNames[3] = (String) "Cent" ;
              changeNames[4] = (String) "Cent" ;
              changeNames[5] = (String) "Cent" ;
              changeNames[6] = (String) "Cent" ;
              return ;
         // calculate the change the user is going to receive
         private static void calcChange(float diffAmount) {
              for (int i = 0; i < changeVar.length ; i++) {
                   if (diffAmount > changeVar) {
                        changeA[i] = (int)(diffAmount / changeVar[i]);
                        diffAmount = diffAmount - (changeA[i] * changeVar[i]) ;
                        System.out.println(changeA[i] + " x " + changeVarNumb[i] + " " + changeNames[i]) ;
              return;
         // output
         public static void main(String[] args) {
              float itemPrice = getInput("Enter product price: ") ;
              float amountTendered = getInput("Enter amount paid: ") ;
              float diffAmount = amountTendered - itemPrice ;
              System.out.println() ;
              System.out.println("Your change is " + diffAmount + " euros") ;
              moneyArray() ;
              calcChange(diffAmount) ;
    And the output looks like this:
    Enter product price:  2.32
    Enter amount paid:  5.00
    Your change is 2.68 euros
    1 x 2 Euro
    3 x 20 Cent
    1 x 5 Cent
    1 x 2 Cent
    1 x 1 Cent                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How many licenses my comapny has and how many number of users logged in.

    Hi All,
    Can any one tell,
    before login into the SAP B1,
    I want to know
    how many licenses my comapny has and how many number of users(Licenced) logged in using Query Analyzer or any other way.
    Thanks
    Chakrapani
    Edited by: chakrapani bandaru on Feb 17, 2010 12:58 PM

    Hi Sunderraj,
    Can u eloberate the answer,
    I want to take a report of that count.
    Thanks
    Edited by: chakrapani bandaru on Feb 17, 2010 2:14 PM

  • Counting how many active sessions in a webapp

    Hi folks,
    I was wondering if it is possible to count how many active sessions that there currently are in a webapp? I've looked at the ServletContext and ServletConfig classes, but I can't find anything. Any ideas?
    Cheers,
    Raj.

    HttpSessionListener was introduced in servlet spec 2.3 which is supported in Tomcat 4.0 but not 3.3.
    If upgrading to 4.0 is not an option, there is no elegant way to get what you need. There is no API call that returns all the active sessions so you must do it yourself. One way is to create a class that implements HttpSessionBindingListener to track your sessions. Instantiate it on start-up and add its reference as a session attribute when the session is first created. You can then update your custom session info in the valueBound and valueUnbound methods.

  • Any idea why in Numbers my COUNTIFS formula keeps breaking? For daycare purpose, I use a spreadsheet that helps me to count how many children I have at 3:15, 4:15 and 5:00. COUNTIFS works well when I create it but breaks after a while. Also I am using a p

    Any idea why in Numbers my COUNTIFS formula keeps breaking? For daycare purpose, I use a spreadsheet that helps me to count how many children I have at 3:15, 4:15 and 5:00. COUNTIFS works well when I create it but breaks after a while. Also I am using a pop-up menu in the cells in time format, does it have any consequence on the formula?

    Any idea why in Numbers my COUNTIFS formula keeps breaking? For daycare purpose, I use a spreadsheet that helps me to count how many children I have at 3:15, 4:15 and 5:00. COUNTIFS works well when I create it but breaks after a while. Also I am using a pop-up menu in the cells in time format, does it have any consequence on the formula?

  • How do count how many 'A' s in this string using sql stmt?

    hi all,
    i have a string like 'AAAAARAMAAAAKRISHNAAAA'.
    in this ,i want to find out how many 'A's .
    how do find out this using select stmt.

    (length(s) - nvl(length(replace(s, 'A')), 0)) / length('A')but consider (by modifying the question slightly to "how do count how many 'AA' s in this string using sql stmt? ")
    SQL>  select (length('AAAAARAMAAAAKRISHNAAAA') - nvl(length(replace('AAAAARAMAAAAKRISHNAAAA', 'AA')), 0)) / length('AA') x from dual
             X
             6
    1 row selected.couldn't I argue that the result should be 10 as e.g. in
    SQL>  select * from xmltable('let $str := "AAAAARAMAAAAKRISHNAAAA"
                            let $search := "AA"
                            for $i in 1 to string-length($str)
                              where substring($str, $i, string-length($search)) = $search
                              return substring($str, $i, string-length($search))' columns x varchar2(10) path '.')
    X        
    AA       
    AA       
    AA       
    AA       
    AA       
    AA       
    AA       
    AA       
    AA       
    AA       
    10 rows selected.Matter of definition I suppose .... ;)
    btw. regexp_count also yields 6:
    SQL>  select regexp_count('AAAAARAMAAAAKRISHNAAAA', 'AA') x from dual
             X
             6
    1 row selected.

  • Hi, I want to know if in the AppStore exist an app that count how many messages I have been used. Thanks

    Hi, I want to know if in the AppStore exist an app that count how many messages I have been used

    Some carriers have iOS apps that will tell you this info...see if yours does, or can't you just login to your account online & see such info?

  • How to count " How many times the ' commit work ' Statement is executed.

    Hi all sap Champions,
    One of the client requirement, That is
    How to count " How many times the ' commit work ' Statement is executed.
    It's urgent.
    Please can anybody help me for this.
    Thanks
    Basu

    hi,
    when report try like this.
    declare a variable as
    data: counter type i value 0.
    COMMIT.
    counter = counter + 1.
    write:/10 counter 'NO. OF TIMES COMMIT WORKED'.

  • How do I count how many songs are on my iPod?

    How do I count how many songs are on my iPod? Also, how do I figure out how much space I have left on it?

    Hi.
    in the ipod under settings>about it says how much room is available. how many songs are on the ipod. other things to.

Maybe you are looking for

  • Did the new iTunes disable my music cds?

    My eMac 700 with combo drive running OS X 10.3.9 and iTunes 7 does not want to play a music cd. I just reinstalled the operating system and nothing changed. How can I uninstall iTunes with all of it's extensions? I believe it has something to do with

  • Frm-41380 error - cannot set the blocks query data source

    Fairly new forms so bare with me. I am creating a form based on one table. This table has one column that is a nested table. table name: szrtime table columns: szrtime_code, szrtime_styp_list szrtime_styp_list is a table of varchar2(1). main block is

  • I just updated to OS X 10.9.3 and lost 3 years of work

    I was in a hurry to instal new software that needed 10.9.3 so I quickly updated it not realising that I needed to make a back up. I now am left with a completely clean slate on my computer.  I seem to have all of my Applications but with not files. A

  • Does not retain window position preferences

    I have a new Mac Pro. When it came it was loaded with Lion. The windows prefernces (position, list view vs column view, etc) wouldn't be retained. This wasn't just between restarts but even if I opened a folder, closed it and opened it a half-hour la

  • Stop automatic send after Form Submit

    Using Acrobat Pro X, Version 10.16 on Windows 7 Professional, Sevice Pack 1.  When a user clicks the Form Submit button it launches an Outlook email and immediately sends an email through Outlook. Is there anyway to allow the user to edit the email,