How to get count of records for each type from internal table

Hi Guys,
I want to implement a logic to find out the count of records in a internal table.
Assume my internal table have one field having the entries as shown below.
Internal table Entries
10
10
10
11
11
12
12
12
12
13
14
14
15
15
15
15
15
16
16
17
18
19
20
20
20
....... etc....
I should get an output as below
10's - 3
11's -2 ,
12's - 4.... etc..
Could any one help me how to do this.
Thanx,
Kumar

REPORT  zzz.
DATA: i(100),
      t(100),
      j TYPE n.
TYPES: BEGIN OF gt_int_type,
        linex(100) TYPE c,
       END OF gt_int_type.
DATA: gt_int TYPE STANDARD TABLE OF gt_int_type,
      wa_int LIKE LINE OF gt_int.
START-OF-SELECTION.
  wa_int-linex = '10'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '10'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '10'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '11'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '11'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '12'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '12'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '12'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '12'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '13'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '14'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '14'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '15'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '15'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '15'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '15'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '15'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '16'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '16'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '17'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '18'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '19'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '20'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '20'.
  APPEND wa_int TO gt_int.
  wa_int-linex = '20'.
  APPEND wa_int TO gt_int.
  LOOP AT gt_int INTO wa_int.
    WRITE:/ wa_int-linex.
  ENDLOOP.
  ULINE.
  SKIP 3.
  SORT gt_int BY linex.
  READ TABLE gt_int INDEX 1 INTO i.
  j = 0.
  LOOP AT gt_int INTO wa_int.
    IF wa_int-linex EQ i.
      j = j + 1.
    ELSE.
      WRITE:/ i,'''s = ', j.
      j = 1.
      i = wa_int-linex.
    ENDIF.
  ENDLOOP.
  WRITE:/ i,'''s = ', j.
consider clearing leading/trainling spaces...

Similar Messages

  • How to get top 10 records for each option in table prompt?

    Hi,
    I have created one report in which my requirement is to get top 10 highest salaries for each departments. I have created one table prompt which contains the names of all departments. On the salary column I have applied one filter i.e. TOP 10. Currently I am having 3 departments. I want to show the top 10 salaries for each department, but I am getting top 3 from first, 4 from second and 3 from third.They are calculating top 10 salaries based on all departments, not on individual department. How can I get top 10 salaries for each department?

    Hi,
    Use TopN function in your column formula.
    Ex: TOPN("Sales ,5 BY department)
    Thanks,
    Satya

  • How to get count of rows for a table?

    Hi,
    How to get count of rows for a table and secondly, how can i have access to a particular cell in a table?
    Regards,
    Devashish

    Hi Devashish,
    WdContext.node<Your_node_name>().size() will give you the no: of rows.
    This should be the node that is bound to the table's datasource property.
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value); will select the row at that particular index.
    You can access an attribute of a particular row as
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value).get<attribute_name>();
    Hope this helps,
    Best Regards,
    Nibu.
    Message was edited by: Nibu Wilson

  • I need a query that selects the amount of records for each day in a table.

    I need a query that selects the amount of records for each
    day in a table.
    Eg the result would be:
    date 1 14
    date 2 3
    etc
    Any ideas?

    sorted:
    SELECT count([commentID]),convert(varchar, dateAdded, 112)
    FROM COMMENTSgroup by convert(varchar, dateAdded,
    112)

  • How to get count as 0 for records not in table

    Hi All,
    I have requirement where I need count of records in the table based on ids. Example query below
    SELECT empid ,
    nvl(COUNT(id), 0) empcount
    FROM employee
    WHERE empid IN(1, 2, 4, 5)
    GROUP BY empid
    In the table only record for "empid=2" is present so I get count 1 for it. But with it I should get count as 0 for non existing records. Expecting below output
    empid | empcount
    1 | 0
    2 | 1
    4 | 0
    5 | 0
    Appreciate your help and Thanks in advance.
    Regards.
    Ashish

    e.g.
    SQL> select column_value deptno, count (deptno)
    from emp, table (sys.odcinumberlist (10, 20, 100))
    where deptno(+) = column_value
    group by column_value
        DEPTNO COUNT(DEPTNO)
            10             3
            20             5
           100             0
    3 rows selected.

  • How to get Privacy Policy value for each userprofile in sharepoint 2010?

    In userprofile application, we have defined Privacy Policy of mobilephone feild as optional, so every user has option to choose visibility scope of this property to "Everyone/My Manager/my colegues/Only Me" .
    Now I am trying to get mobilephone value and their selected visibility option for each user.
    I am able to get mobilephone value but I could not get "what each user has chosen as their visibility scope"?

    Hi,
    According to your post, my understanding is that you want to get Privacy Policy value for each userprofile in sharepoint 2010.
    You need to use RunWithElevatedPrivileges method to impersonate user.
    To get the get mobilephone policy, you can use user["CellPhone "].Privacy.
    For more information, you can refer to:
    c# - Getting property privacy with Sharepoint 2010
    How to Programmatically Impersonate Users in SharePoint
    Managing Sharepoint 2010 Profiles Programmatically
    Thanks,
    Linda Li                
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Linda Li
    TechNet Community Support

  • How to get the time interveral for each status of worklow (wating,Inprocess

    Hi Friends,
    I have requreiemnt to get the time interval for each status of workflow.
    ex.
                                                                     status
    workflow id  | startd date | enddate       | waiting | Inprocessing|Error|......
    1026            10.10.2008  25.10.2008        1hr      1hr 30 min    2 hr
    Please do give me idea how to get the time stam of each status of workflow.
    Thanks,
    D.prabhu

    Hi,
    I think the following tables would be helpful to you:-
    SWW_CONT     Container Contents for Work Item Data Container
    SWW_CONTOB     "Container Cont. for Work Item Data Container (Only Objects)"     
    SWWLOGHIST     History of a work item     
    SWWORGTASK     Assignment of WIs to Org.Units and Tasks     
    SWWUSERWI      Current Work Items Assigned to a User     
    SWWWIHEAD     Header Table for all Work Item Types
    Hope it Helps!
    Regards,
    Kanika

  • How to get all GL accounts for each account in a given bank...

    Hello Experts,
    Is there a way to get all GL accounts for each account in a given house bank?
    IN our company, there are 5 GL accounts for each bank so 1 GL for 1 account. they are for recon, payables,
    receivables, etc. I checked table T012K but it only shows the main GL account. Hope you
    can help me guys. Thank you and take care!

    Try this.. it is based on company code
    here it_cocodes is an internal table containing company codes
      DATA: BEGIN OF it_glaccount OCCURS 0,
        bukrs TYPE bukrs,
        saknr TYPE saknr,
        txt50 TYPE txt50_skat,
       END OF it_glaccount.
      DATA it_glaccount_wa LIKE it_glaccount.
    LOOP AT it_cocodes INTO it_cocodes_wa WHERE ktopl <> ''.
        SELECT bukrs saknr FROM skb1
          INTO CORRESPONDING FIELDS OF it_glaccount_wa
          WHERE bukrs = it_cocodes_wa-bukrs.
          IF sy-subrc = 0.
            SELECT SINGLE txt50 FROM skat INTO it_glaccount_wa-txt50
              WHERE spras = 'E' AND ktopl = it_cocodes_wa-ktopl
              AND saknr = it_glaccount_wa-saknr.
            APPEND it_glaccount_wa TO it_glaccount.
            CLEAR it_glaccount_wa-txt50.
          ENDIF.
        ENDSELECT.
    loop at it_glaccount into it_glaccount_wa.
    write:/....
    endloop.
    refresh...
    clear...
    endloop.

  • How to get multiple output formats for each execution of the report?

    Hi,
    Is it possible to get multiple output formats for each execution of the report? If so can you provide some details?
    Thanks

    In Reports 6i, Reports Distribution was introduced. This allows you to run the report once and output to a number of destinations with a different format. It also allows you to distribute individual sections within a report to different destinations in different formats.
    The Destinations for a Report to distribute to are defined either in a distribution file and passed on the command line or inside of the report definition.
    To add a destination to the the report definition, bring up the property palette against the report object and then select the "Distribution" property under the "Report" node. This will bring up a dialog that allows you to create a distribution list. You can then test this list by selecting "file->distribute" from the menu.
    To run a report that is to be distributed through rwrun60, you need to add "distribute=yes" to the command line. It will pick up the destinations from the report definition. If you add "destination=<filename>" then it will pick up the destinations from the specified "<filename>" and ignore the destinations in the report definition.
    Note: if "distribute=yes" is specified on the command line then the destype/desname/desformat parameters will be used to format the report (ie: which printer/display to use during formatting for sizing objects) but will be ignored when the report is sent to the destinations.

  • How to get mobile model name for different types mobile devices

    Hi,
    I have checked few thread in this forum about getting mobile model name at server. So far, i noticed the mobile name is set manually in the midlet as user-agent .
    HttpConnection connection = null;           connection = (HttpConnection)Connector.open(url);          connection.setRequestMethod(HttpConnection.POST);          connection.setRequestProperty("User-Agent","Nokia7110 Profile/MIDP-1.0 Configuration/CLDC-1.0");
    i retrieve the header information from servlet like below :-
    String userAgent = request.getHeader("User-Agent");
    How to get mobile model name for different model devices , not by manually adding the model name in midlet?
    Thanks in advance :-)

    Hi,
    In J2ME there is no method to get the model number from the device. how ever you can use the APIs provided by the device manufacturer if available. But still the APIs will not work with devices from other manufacturer or sometimes it will not work with the devices of the same manufacturer if the API is not supported. so it is better to send the device model name through the header.

  • OBIEE - How to get count of members for a level?

    I have a dimension logical table and hierarchy defined in my BMM layer. I want to define a logical column that can get distinct count of members at Level0.
    Level2
    Level1
    Level0
    I tried creating a logical column using Level0 key and Count Distinct aggregation function in my dimension table. But when I use this column in the report, it gives navigation space error.
    Any ideas/thoughts on how to achieve this?
    Thanks in advance

    Aggregations always work on columns in a logical fact table and never on a logical dimension
    - Create a logical fact table based on the same physical table
    - Create a logical join between the newly created fact table and the dimension table whose levels we want to count
    - Create the Count Distinct columns, one each based on the level key columns
    - Expose the columns to the presentation
    - Deploy the rpd and it works like a charm
    Edited by: Mahesh Jayashankar on May 31, 2011 8:45 AM

  • Get count of officers for each company

    Hi, all. I need to get the count of officers from each company from the following data,
    CompanyID OfficerID
    1234 4456
    1234 2087
    1234 1298
    7765 2376
    9987 5423
    9987 2965
    What I need is the following for the above data,
    CompanyID OfficerCount
    1234 4
    7765 1
    9987 2
    What SELECT will get me this data? Thank you.

    Thanks, Dishoom! That worked like a charm! Been working on that problem, thinking it's going to require something complicated. You solved it in 3 lines. Thank :)

  • Query to count ACTIVE records for each month

    All,
    I have a requirement to count the number of active customers for each month of an year. Let's say, we have 3 fields in the table:
    ID               ActiveStart             ActiveEnd
    1                 1/1/2014               11/30/2014
    In this scenario, the member with ID was active for all the months (Jan-November) EXCEPT, December. So, the result set I am expecting for the Month of January to December is like below:
    Month       CountOfMembers
    Jan            1
    Feb           1
    Mar           1
    April          1
    May           1
    June          1
    July           1
    August      1
    Sept          1
    Oct            1
    Nov           1
    Dec           0 (Since, the member was NOT active in this month)
    Similarly, if you have another member whose start date is 1/1/2014 and termination is '5/31/2014', then, I would need to add 1 for months of January till May, the member WON'T be counted for the rest of the months. So, in this case, the count will be come
    "2" for months January till May, it will remain "1" for June till November and still "O" for December.

    >>I have a requirement to count the number of active customers for each month of an year. Let's say, we have 3 fields [sic: columns are not fields] in the table [sic: tables have names]: <<
    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI-ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need to
    know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI-ISO Standard SQL. And you need to read and download the PDF for: 
    https:--www.simple-talk.com-books-sql-books-119-sql-code-smells-
    There is no magical universal “id” in RDBMS, tables have names and columns have constraints and types. Most of the work in SQL is done in the DDL. Here is a possible schema. 
    CREATE TABLE Duty_Roster
    (member_nbr INTEGER NOT NULL PRIMARY KEY,
     duty_start_date DATE NOT NULL,
     duty_end_date DATE NOT NULL,
    CHECK (duty_start_date <= duty_end_date),
    INSERT INTO Duty_Roster
    VALUES 
    (1, '2014-01-01', '2014-11-30'),
    (2, '2014-01-01', '2014-05-31');              
    >> In this scenario, the member with ID was active for all the months (Jan-November) EXCEPT, December. So, the result set I am expecting for the Month of January to December is like below: <<
    A month is a temporal measurement that makes no sense without a year. But if you knew the ISO temporal model, you would see that you have what is called an INTERVAL data type. T-SQL does not support it yet. 
    Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements in the DML.
    The report period table gives a name to a range of dates that is common to the entire enterprise. 
    CREATE TABLE Month_Periods
    (month_name CHAR(10) NOT NULL PRIMARY KEY
       CHECK (month_name LIKE  '[12][0-9][0-9][0-9]-[01][0-9]-00'),
     month_start_date DATE NOT NULL,
     month_end_date DATE NOT NULL,
      CONSTRAINT date_ordering
        CHECK (month_start_date <= month_end_date),
    etc);
    These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
    data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00'
    SELECT M.month_name, COUNT(R.member_nbr) AS member_cnt
      FROM Month_Periods AS M,
           Duty_Roster AS R
     WHERE M.month_start_date 
           BETWEEN R.duty_start_date AND R.duty_end_date
       AND M.month_end_date 
           BETWEEN R.duty_start_date AND R.duty_end_date;
    We had no business rules about partial months, so I guessed. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to get only updated records for a column using loading type INSERT

    Hi,
    Good morning all,
    I have source1 containg 3 columns bill_cd,bill_desc,bill_date and
    source2 has the columns bill_cd,bill_key,source_id.
    My target has the columns bill_cd,bill_date,bill_desc .
    Now the requirement is, bill_cd in target should not repeated when we run the mapping more than one thime. it should get only updated records not the previous records using only INSERT Loading type(for target) not to use update/insert.
    How can we achieve this logic in mapping level.
    Anybody Please give me some solution immediately.
    Thanks in Advance,
    Siv

    Thanks Herzog for your reply,
    Here bill_cd is not unique. Yes,I want only new records using INSERT as loading type. Suppose when the map runs for the first time, bill_cd is loaded with values 1 to 5.
    Now, in the source I have got new records 6 to 10 for bill_cd and when I run the mapping again I need to get only records for bill_cd from 6 to 10 using INSERT as loading type.
    Is it possible to achieve this at mapping level?
    Regards,
    Siv.

  • How to get count of records inserted and errored out in an email

    Hi
    I have following question
    I want to send report statics of scenario i.e Number of rows inserted during the scenario and
    Number of rows in error in the scenario in an email.Here in my scenario I am trying to insert data into Essbase database and when i try to use getNbInserts() and getNbErrors functions of ODI in an email body,its giving zero value even though there 140 records inserted and 10 errored out.Can any one let me know how we get this number of records inserted and number of records errored in email.
    Thanks in advance
    Regards
    Baji

    Hi
    I have following question
    I want to send report statics of scenario i.e Number of rows inserted during the scenario and
    Number of rows in error in the scenario in an email.Here in my scenario I am trying to insert data into Essbase database and when i try to use getNbInserts() and getNbErrors functions of ODI in an email body,its giving zero value even though there 140 records inserted and 10 errored out.Can any one let me know how we get this number of records inserted and number of records errored in email.
    Thanks in advance
    Regards
    Baji

Maybe you are looking for