ALV Count the records in group

I have a report which list the billing documents which sort and group by sales office. The layout is something like this
Sales Office      Billing Document    Amount
A                      0001                     1000
A                      0002                     1000
Doc. count = 2
B                      0003                     1500 
Doc. count = 1
I know that I can add a column with the value 1 in each cell and sum them up.
Is that any other alternatives?

Hi,
Where do you want to show this count. Do you want to show it as the column in output or in the header of the ALV. You can just see the entries in the output table and print that count.
Reward points if useful.
Regards,
Atish

Similar Messages

  • Need to count the number of groups in a Crystal Reports 2008 report

    I have created a report with three levels of grouping. There are several items in each level.  I want to count the number of groups.  I have tried countdistinct but it counts the number of items in the lowest level of grouping and I want the number of items in the higher  levels.  This is a distribution data base.  I have the data grouped by date, by truck on each date, and by "run" or load on each truck on each date.  I want to count the total number of groups of truck and run, which is the second level of the grouping.  Any ideas? I am fairly new to Crystal.

    Hi Debbie,
         To count the number of groups please try the folling steps:
    1) Create a formula @reset and place this formula in the page header
        whileprintingrecords;
        numbervar i:=0;
    2) Create another formula @evalgroup place this in the group header where you want to count the values.
        whileprintingrecords;
        numbervar i:= i+1;
    3) Create another formula @display and place this in report footer.
        whileprintingrecords;
        numbervar i;
    In order to display the count of details which are printing in the detail section place the eval formula in the detail section and the @display formula in the group footer.
    Hope this helps!!!
    Regards,
    Vinay

  • Count the Records in  an internal table without a loop.

    How do i count the number of records in an internal table without using the loop  statement.
    The Describe statement give the total no. of records in the internal table.But i want the count of the key fields in the internal table
    For eg
    Row Field
    1       A
    2       A
    3       A
    4       B
    5       B
    6       C
    Count of A = 3
    Count of B = 2
    Count of C = 1

    Dilip,
      I think isn't posible. Only 3 ideas:
    1ª, make other table "table2", similar to your actual table.
         table2[] = yourtable[].
         delete table2 where key <> 'A'.
         describe table table2 lines contA.
        But depending the amount of data, you may have problems in performance or memory consumption...
    2ª, make other table, only with the keys fields and a count field,
        data begin table2
           key_field1,
           cont type i.
        end data.
       when you append lines to yourdata, make a collect to this table:
        table2-keys = yourtable-keys.
        table2-cont = 1.
       collect table2.
       But only works if you can modify the program where data is appended, and you may be carefull when data is deleted :-(...
    3ª if your data if filled in a select, you may fill the table2 of point 2ª, making a similar select but:
       select keyfields count( * ) into table table2
      from ...
      where (the same you have to fill your original table...)
       group by keys.
    But you have the same problem is data is deleted later...
    I hope that any of the three is useful for you...
    Edited by: Diego Alvarez on Jan 5, 2010 5:09 PM

  • Count the records

    i have two tables like master and child having below records.Please find the records.
    Master table
    CODE STATUS
    ABC U
    ABC S
    Histrory Table
    CODE status
    ABC S
    I WANT THE RESULT
    STATUS COUNT
    U 1
    S 2
    i am using below query it is not working,It shows only for status(S) count 3 not for Status U.How shall we count this reocrd.,
    SELECT x+y as total from
    select count(1) x,staus from master
    where code like 'AB%' group by status
    select count(1) y,status from history
    where code like 'AB%' GROUP BY STATUS)

    Hello
    You need to union all the two tables together:
    tylerd@DEV2> CREATE TABLE dt_test_code_table
      2  (   col1    VARCHAR2(3),
      3      col2    VARCHAR2(1)
      4  )
      5  /
    Table created.
    Elapsed: 00:00:00.36
    tylerd@DEV2> CREATE TABLE dt_test_code_table_hist
      2  (   col1    VARCHAR2(3),
      3      col2    VARCHAR2(1)
      4  )
      5  /
    Table created.
    Elapsed: 00:00:00.04
    tylerd@DEV2>
    tylerd@DEV2> INSERT INTO dt_test_code_table VALUES('ABC','U')
      2  /
    1 row created.
    Elapsed: 00:00:00.01
    tylerd@DEV2> INSERT INTO dt_test_code_table VALUES('ABC','S')
      2  /
    1 row created.
    Elapsed: 00:00:00.00
    tylerd@DEV2> INSERT INTO dt_test_code_table_hist VALUES('ABC','U')
      2  /
    1 row created.
    Elapsed: 00:00:00.00
    tylerd@DEV2>
    tylerd@DEV2> SELECT
      2      COUNT(*),
      3      col2
      4  FROM
      5      (   SELECT
      6              col2
      7          FROM
      8              dt_test_code_table
      9          UNION ALL
    10          SELECT
    11              col2
    12          FROM
    13              dt_test_code_table_hist
    14      )
    15  GROUP BY
    16      col2
    17  /
      COUNT(*) C
             2 U
             1 S
    2 rows selected.
    Elapsed: 00:00:00.03HTH
    David
    Message was edited by:
    David Tyler
    Eric beat me too it! :-)

  • To count the records in the database table...

    I want to count the number of records in the database table (infotypes PA0000)
    is it possible to count ?
    Any function module is there?
    Thanks in advance..

    Hi dhavamani ponnusamy,
    SELECT COUNT(*) FROM <DB TABLE NAME> WHERE <CONDITION>.
    or
    SY-DBCNT Will have total no of records satisfying the given criteria in where clause.
    See below sample..
    Data: itab like mara occurs 0 with header line.
    Select * from mara into table mara.
    write:/ sy-dbcnt.
    Hope it will solve your problem...
    Reward points if useful..
    Thanks & Regards
    ilesh 24x7

  • A column that counts the records......need some help

    say i have a table with values {a, b, c, d, f};
    i want a column that counts the rows of these records with out putting the value manually.
    COL1 COL2
    0 a
    1 b
    2 c
    3 d
    4 f
    I have created a data block (wizard) for inserting the values into the table. But i want it to insert the values in COL1 automatically. Seems easy but i dont seem to be able to figure this out...

    with tab1 as
    (select 'a' col2 from dual
    union all
    select 'b' col2 from dual
    union all
    select 'c' col2 from dual
    union all
    select 'd' col2 from dual
    union all
    select 'f' col2 from dual
    -- End of test data
    select rownum - 1 col1, col2 from
    (select col2 from tab1 order by col2)
    COL1 COL2
    0 a
    1 b
    2 c
    3 d
    4 f Regards
    Dmytro

  • Count the record satisfied daily, weekly conditions

    Hi,
    I have a table which with the data being populated hourly (as below - with Date, Name, Value1, Value2 fields).
    I would need to query to get:
    1. Daily: Count the number of record which have Value1 <10 or Value2 >4 and occurs at least 3 times per day.
    2. Weekly: Count the number of record which satisfied the condition in "Daily" and happens 7 days consecutively for the past week.
    Thank you very much.
    Alex
    Table ABC               
    Date     Name Value1     Value2
    12/04/2010:01:00     TEST1     10     5
    12/04/2010:02:00     TEST1     10     4
    12/04/2010:03:00     TEST1     9     4
    12/04/2010:04:00     TEST1     9     4
    12/04/2010:05:00     TEST1     10     4
    18/04/2010:01:00     TEST1     10     4
    18/04/2010:02:00     TEST1     9     4
    18/04/2010:03:00     TEST1     9     3
    18/04/2010:04:00     TEST1     9     3
    Edited by: user8606416 on 16-Apr-2010 02:39

    We often help students ... but we insist that students help themselves too.
    The first thing you can do is read the FAQ and learn how to format listings with tags so we can read them.
    The second is that they try not just ask for a solution far more sophisticated than they could write themselves. I don't see evidence that you have tried to solve this yourself.
    BTW: DATE and NAME are reserved words in Oracle and should never be used to name anything.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to count the records?

    Hi,
    My data in the report is like below:
    INVOICE# DATE QTY
    ==============================
    111 07/03/03 1
    RT1 07/05/03 1
    222 07/08/03 2
    333 07/09/03 2
    RT2 07/10/03 1
    Is there any way that I can sum the QTY OF all the 'RT' invoice#?
    Thanks,
    Jun

    Hi
    Just put a Reports lavl summary column that sums the QTY column. You can have the summary column at the page and group level also.
    Thanks
    Rohit

  • How to return the record count of a query to a number variable

    How would I get the record count from a query without using a cursor to step through the query and count the records individually?
    query: select * from table1 where column1 = column2
    How would I get the record count of the query above?
    thanks,
    michelle

    I figured it out
    select count(*) into theCount
    from ( select * from table1 where column1=column2 );
    thanks,
    michelle

  • Need a relative sequence (count of record) in an input file in ESB input fi

    I am using ESB to pick up text files and pass them to a stored procedure. I have multiple variable length records in the file. I pass each record to the
    output file adapter, along with the input filename. I would also like to get a relative record number for each record within the file. I use an xsd file
    to convert the input to XML. The entire file is at the root level, each record is an element. Is there a way to get a relative count of each element?
    Here is the xsd file:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    targetNamespace="http://TargetNamespace.com/Filein"
    xmlns:tns="http://TargetNamespace.com/Filein"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified" nxsd:encoding="ASCII" nxsd:stream="chars" nxsd:version="NXSD">
    <xsd:element name="Root-Element">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="C1" minOccurs="1" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="C1" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="&quot;">
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    <!--NXSDWIZ:J:\\UPLD5383.INM:-->
    <!--USE-HEADER:false:-->
    I need to map the relative record number to a field in the output.
    Is there a function similar to the get filename that would return this value to me?
    <xsl:value-of select='ehdr:getRequestHeader("/fhdr:InboundFileHeaderType/fhdr:fileName","fhdr=http://xmlns.oracle.com/pcbpel/adapter/file/;")'/>
    I use this in the xsl file to get the file name .

    does each record start with a new line? if it does a
    simple wc -l can help you. If not, you can pre
    process this XML file by first removing all the new
    line characters using sed and then adding new line
    characters after the end tag of the xml using sed and
    finally doing a wc -l . this would be a simple shell
    script. Not sure if you want to use Unix shell
    scripting to achieve this.The sheer nature of XML means that it does not conform to any visual formatting. i.e. An xml file containing...
    <employee><empno>3</empno></employee>
    is identical in XML terms to...
    <employee>
    <empno>3</empno>
    </employee>
    which is also identical in XML terms to...
    <employee>
    <empno>
    3
    </empno>
    </employee>
    which is also identical in XML terms to...
    <employee><empno>
    3
    </empno></employee>
    etc.
    You cannot rely on the number of CR's or CR/LF's in the file to count the records. Proper XML processing should be used for such a task.

  • Need to count the number of times the Basic Finish data chages

    HI Expertes,
    I have a requirement I need to count number of times the Basic finish date chaged for PM work order. I went throug our forums I got some info like using a standard function module
    CHANGEDOCUMENT_READ_HDRS_ONLY
    CHANGEDOCUMENT_READ_HEADERS
    CHANGEDOCUMENT_READ_POSITIONS
    But all the above function module will not be suitable for my requirement since  CHANGEDOCUMENT_READ_HDRS_ONLY it gives whole changes but my requirement is just need number of changes occurred in Basic Finish date but CHANGEDOCUMENT_READ_POSITIONS can give the filed number which has been changed but still I need change id.
    So kindly suggest me wether there is any other Standard FM to get number of changes occurred in Basic Finish date?
    Thanks,
    Rajesh

    Hi Debbie,
         To count the number of groups please try the folling steps:
    1) Create a formula @reset and place this formula in the page header
        whileprintingrecords;
        numbervar i:=0;
    2) Create another formula @evalgroup place this in the group header where you want to count the values.
        whileprintingrecords;
        numbervar i:= i+1;
    3) Create another formula @display and place this in report footer.
        whileprintingrecords;
        numbervar i;
    In order to display the count of details which are printing in the detail section place the eval formula in the detail section and the @display formula in the group footer.
    Hope this helps!!!
    Regards,
    Vinay

  • How can I get a count of records in a DB?

    If I want to get a count of the number of records in a table how do I do it?

    Generally, it's good practice to close the connection once you're done with it unless you have a reason to keep going back to it, in which case it probably becomes a performance issue. If you need to keep accessing the same connection repeatedly while your form is running (in Acrobat), I think you would be best to leave it open after initialization.<br /><br />You might consider placing the code which counts the records into a function inside a Script Object. This way, you can just call the Script Object method and retrieve the record count whenever you need it.<br /><br />Make sure you define the <b>oDB</b> variable outside the function but inside the Script Object:<br /><pre>var oDB = null;<br /><br />function GetRecordCount()<br />{<br />  if (oDB == null)<br />  {<br />    var sDataConnectionName = "<value>"; // example - var sDataConnectionName = "MyDataConnection"; <br /><br />    // Search for sourceSet node which matchs the DataConnection name <br />    var nIndex = 0; <br />    while(xfa.sourceSet.nodes.item(nIndex).name != sDataConnectionName) <br />    { <br />      nIndex++; <br />    } <br /><br />    var oDB = xfa.sourceSet.nodes.item(nIndex); <br />    oDB.open();<br />  }<br /><br />  oDB.first(); <br /><br />  // Search node with the class name "command" <br />  var nDBIndex = 0; <br />  while(oDB.nodes.item(nDBIndex).className != "command") <br />  { <br />    nDBIndex++; <br />  } <br /><br />  // Backup the original settings before assigning BOF and EOF to stay <br />  var sBOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("bofAction"); <br />  var sEOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("eofAction"); <br /><br />  oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayBOF", "bofAction"); <br />  oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayEOF", "eofAction"); <br /><br />  var itemCount = 0; <br /><br />  while(!oDB.isEOF()) <br />  { <br />    itemCount++; <br />    oDB.next(); <br />  } <br /><br />  // Restore the original settings <br />  oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sBOFBackup, "bofAction"); <br />  oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sEOFBackup, "eofAction"); <br /><br />  return itemCount;<br />}</pre><br />You can create a script object by right-clicking on the top-level form node ("form1" by default). Say you name your script object "Utils", you can then call the function inside of it from any event script like this:<br /><pre>this.rawValue = Utils.GetRecordCount();</pre><br />Stefan<br />Adobe Systems

  • Count the number of records in a group

    Hi ,
    My requirement is to display in the BI reprt - records in Order Entry Line Items based on several conditions on the fields.
    If the above conditions do not returm any records ,show an error message - NO DATA FOUND.
    1.checked in standard RTF templates where its a simple example as if :not(//servicereq).
    But ,my RTF has serveral conditions on the group.
    2.Is there a way to take a count of records in the group which statisfy the given condotions,so that I can checkif count = 0 .dislay message.
    Apreciate your help.
    Regards.

    Ummmmm...no I didn't, hate to admit it.
    Added the declaration to the 2 percentage formulas. Now I do get results for the percentage...they are just wrong. Only pattern I've found is that if the running total of Int or Ext is 1, the percentage is 11.39. If it is 2, the percentage is 22.78 and so on.
    Each percentage is a multiple of 11.39 depending on the respective running total calculation. Maybe you can see what I have obviously missed.
    NAME........TOTAL.......TOTAL Int........% Int........TOTAL Ext........%Ext
    Burberry........20..............4..................45.56.............16 ..............182.23
    Cellarosi.......11..............1 .................11.39.............10................113.90
    Chalkley.......19..............2..................22.78.............17................193.62

  • How to devide the set of records into groups in SQL itself.

    Hi , i am using 10.2.4.0 of oracle.
    I am having one requirement, in which i have to devide the set of records into certain groups , so that they can be executed partly but not in one run.
    So in the 'SELECT' clause itself i want to asssign particular value (may be 1 )to first 50000 records then another value(may be 2) to next 10000, like wise. And again the total count of records will also varry time to time , if the total count of record set is less than 10000 , then it should only assign '1' to all the records. i will set the group values (1,2,3...) as another column itself.
    Can you please let me know if this can be done in SQL without going for PLSQL?

    Hi,
    That's called a Pagination Query , and here's one way to do it:
    WITH     got_grp          AS
         SELECT     x.*
         ,     CEIL ( ROW_NUMBER () OVER (ORDER BY  x_id) 
                   / 50000
                   )          AS grp
         FROM     table_x  x
    --     WHERE     ...          -- If you need any filtering, put it here
    SELECT     *               -- Or list the columns you want
    FROM     got_grp
    WHERE     grp     = 1
    ;ROW_NUMBER () OVER (ORDER BY x_id)     assigns unique integers 1, 2, 3, ... to all all rows, in the same order as x_id (even if x_id is not unique).
    CEIL (ROW_NUMBER () OVER (ORDER BY x_id) / 50000)     maps the 1st 50,000 of those numbers to 1, the 2nd 50,000 to 2, and so on.
    Analytic functions (like ROW_NUMBER) as computed after the WHERE clause is applied, so, to use the results in a WHERE clause, then you need to compute them in a sub-query. If you just want to display the number, and not use it in a WHERE clause, then you don't need a sub-query.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using.
    See the forum FAQ {message:id=9360002}

  • How can we get record numbers for the rows after grouping them?

    Post Author: preethibaddam
    CA Forum: Formula
    hii everyone,
    i want to number those records which are grouped by a column.
    eg: if i group the emp table with the deptno then the records for the deptno10 group should start from 1 and end with an N number and again when it shifted to deptno20 group than the records for that deptno20 should again start with 1 and end with N number.
    i tried placing record number from the field explorer but it is not working. the other group records start with the ended number from the first group.
    thanks

    Post Author: V361
    CA Forum: Formula
    Record number from CR will count all the records.  You could use a running total, and reset on change of group.

Maybe you are looking for