<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: COLLECT in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547120#M579510</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COLLECT summarizes all numberic fields based on the non-numeric fields contents.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For Example &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Summarized sales figures by company: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF COMPANY, &lt;/P&gt;&lt;P&gt;        NAME(20) TYPE C, &lt;/P&gt;&lt;P&gt;        SALES    TYPE I, &lt;/P&gt;&lt;P&gt;      END OF COMPANY. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;DATA: COMP    TYPE COMPANY, &lt;/P&gt;&lt;P&gt;      COMPTAB TYPE HASHED TABLE OF COMPANY &lt;/P&gt;&lt;P&gt;                                WITH UNIQUE KEY NAME. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;COMP-NAME = 'Duck'.  COMP-SALES = 10. COLLECT COMP INTO COMPTAB. &lt;/P&gt;&lt;P&gt;COMP-NAME = 'Tiger'. COMP-SALES = 20. COLLECT COMP INTO COMPTAB. &lt;/P&gt;&lt;P&gt;COMP-NAME = 'Duck'.  COMP-SALES = 30. COLLECT COMP INTO COMPTAB&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table COMPTAB now has the following contents: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NAME | SALES &lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------" /&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Duck | 40 &lt;/P&gt;&lt;P&gt;Tiger | 20 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, check this thread&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="361888"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Jul 2007 06:58:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-07-17T06:58:43Z</dc:date>
    <item>
      <title>COLLECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547112#M579502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can any one pls explain COLLECT keyword with example?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 06:45:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547112#M579502</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T06:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: COLLECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547113#M579503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;here is sample code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF seats, &lt;/P&gt;&lt;P&gt;        carrid   TYPE sflight-carrid, &lt;/P&gt;&lt;P&gt;        connid   TYPE sflight-connid, &lt;/P&gt;&lt;P&gt;        seatsocc TYPE sflight-seatsocc, &lt;/P&gt;&lt;P&gt;      END OF seats. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA seats_tab LIKE HASHED TABLE OF seats &lt;/P&gt;&lt;P&gt;               WITH UNIQUE KEY carrid connid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT carrid connid seatsocc &lt;/P&gt;&lt;P&gt;       FROM sflight &lt;/P&gt;&lt;P&gt;       INTO seats. &lt;/P&gt;&lt;P&gt;  COLLECT seats INTO seats_tab. &lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards &lt;/P&gt;&lt;P&gt;Ravish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 06:48:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547113#M579503</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T06:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: COLLECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547114#M579504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Collect:&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF COMPANIES OCCURS 10,&lt;/P&gt;&lt;P&gt;        NAME(20),&lt;/P&gt;&lt;P&gt;        SALES TYPE I,&lt;/P&gt;&lt;P&gt;      END   OF COMPANIES.&lt;/P&gt;&lt;P&gt;COMPANIES-NAME = 'Duck'.  COMPANIES-SALES = 10.&lt;/P&gt;&lt;P&gt;COLLECT COMPANIES.&lt;/P&gt;&lt;P&gt;COMPANIES-NAME = 'Tiger'. COMPANIES-SALES = 20.&lt;/P&gt;&lt;P&gt;COLLECT COMPANIES.&lt;/P&gt;&lt;P&gt;COMPANIES-NAME = 'Duck'.  COMPANIES-SALES = 30.&lt;/P&gt;&lt;P&gt;COLLECT COMPANIES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table COMPANIES now has the following appearance: &lt;/P&gt;&lt;P&gt;Duck 	40&lt;/P&gt;&lt;P&gt;Tiger	 20&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the line is inserted, the system checks whether there is already a table entry that matches the key. &lt;/P&gt;&lt;P&gt;If there is no corresponding entry already in the table, &lt;/P&gt;&lt;P&gt;the COLLECT statement has the same effect as inserting the new line. &lt;/P&gt;&lt;P&gt;If an entry with the same key already exists, &lt;/P&gt;&lt;P&gt;the COLLECT statement does not append a new line,&lt;/P&gt;&lt;P&gt;but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entry. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should only use the COLLECT statement if you want to create summarized tables.&lt;/P&gt;&lt;P&gt;If you use other statements to insert table entries, you may end up with duplicate entries.&lt;/P&gt;&lt;P&gt;GO THROUGH THIS LINK&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm" target="test_blank"&gt;http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Can i use a collect statement here&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We can use collect statement in all internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. The only MAIN CONCEPT is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. that it will SUM up the Quantity fields,&lt;/P&gt;&lt;P&gt;based upon &lt;/P&gt;&lt;P&gt;the COMBINATION of all Character Fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;Reshma&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 06:50:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547114#M579504</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T06:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: COLLECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547115#M579505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Debarshi,&lt;/P&gt;&lt;P&gt;please have a look at &amp;lt;a href="http://help.sap.com/saphelp_46c/helpdata/en/fc/eb36d5358411d1829f0000e829fbfe/frameset.htm"&amp;gt;SAP Help on COLLECT statement&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps. Best regards,&lt;/P&gt;&lt;P&gt;Alvaro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 06:50:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547115#M579505</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T06:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: COLLECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547116#M579506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax Diagram &lt;/P&gt;&lt;P&gt;COLLECT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basic form &lt;/P&gt;&lt;P&gt;COLLECT [wa INTO] itab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Extras: &lt;/P&gt;&lt;P&gt;1. ... ASSIGNING &amp;lt;fs&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. ... REFERENCE INTO dref &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. ... SORTED BY f &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Short Forms in Line Operations. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;COLLECT allows you to create unique or summarized datasets. The system first tries to find a table entry corresponding to the table key. (See also Defining Keys for Internal Tables). The key values are taken either from the header line of the internal table itab, or from the explicitly-specified work area wa. The line type of itab must be flat - that is, it cannot itself contain any internal tables. All the components that do not belong to the key must be numeric types ( ABAP Numeric Types). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the system finds an entry, the numeric fields that are not part of the table key (see ABAPNumeric Types) are added to the sum total of the existing entries. If it does not find an entry, the system creates a new entry instead. &lt;/P&gt;&lt;P&gt;The way in which the system finds the entries depends on the kind of the internal table: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STANDARD TABLE: &lt;/P&gt;&lt;P&gt;The system creates a temporary hash administration for the table to find the entries. This means that the runtime required to find them does not depend on the number of table entries. The administration is temporary, since it is invalidated by operations (such as DELETE, INSERT, MODIFY, or SORT). A subsequent COLLECT is then no longer independent of the table size, because the system has to use a linear search to find entries. For this reason, you should only use COLLECT to fill standard tables. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORTED TABLE: &lt;/P&gt;&lt;P&gt;The system uses a binary search to find the entries. There is a logarithmic relationship between the number of table entries and the search time. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HASHED TABLE: &lt;/P&gt;&lt;P&gt;The system uses the internal hash administration of the table to find records. Since (unlike standard tables), this remains intact even after table modification operations, the search time is always independent of the number of table entries. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For standard tables and SORTED TABLEs, the system field SY-TABIX contains the number of the existing or newly-added table entry after the COLLECT. With HASHED TABLEs, SY-TABIX is set to 0. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notes &lt;/P&gt;&lt;P&gt;COLLECT allows you to create a unique or summarized dataset, and you should only use it when this is necessary. If neither of these characteristics are required, or where the nature of the table in the application means that it is impossible for duplicate entries to occur, you should use INSERT [wa INTO] TABLE itab instead of COLLECT. If you do need the table to be unique or summarized, COLLECT is the most efficient way to achieve it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use COLLECT with a work area, the work area must be compatible with the line type of the internal table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you edit a standard table using COLLECT, you should only use the COLLECT or MODIFY ... TRANSPORTING f1 f2 ... statements (where none of f1, f2, ... may be in the key). Only then can you be sure that: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-The internal table actually is unique or summarized &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-COLLECT runs efficiently. The check whether the dataset &lt;/P&gt;&lt;P&gt;already contains an entry with the same key has a constant &lt;/P&gt;&lt;P&gt;search time (hash procedure). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use any other table modification statements, the check for entries in the dataset with the same key can only run using a linear search (and will accordingly take longer). You can use the function module ABL_TABLE_HASH_STATE to test whether the COLLECT has a constant or linear search time for a given standard table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Summarized sales figures by company: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF COMPANY, &lt;/P&gt;&lt;P&gt;NAME(20) TYPE C, &lt;/P&gt;&lt;P&gt;SALES TYPE I, &lt;/P&gt;&lt;P&gt;END OF COMPANY. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: COMP TYPE COMPANY, &lt;/P&gt;&lt;P&gt;COMPTAB TYPE HASHED TABLE OF COMPANY &lt;/P&gt;&lt;P&gt;WITH UNIQUE KEY NAME. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COMP-NAME = 'Duck'. COMP-SALES = 10. COLLECT COMP INTO COMPTAB. &lt;/P&gt;&lt;P&gt;COMP-NAME = 'Tiger'. COMP-SALES = 20. COLLECT COMP INTO COMPTAB. &lt;/P&gt;&lt;P&gt;COMP-NAME = 'Duck'. COMP-SALES = 30. COLLECT COMP INTO COMPTAB. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table COMPTAB now has the following contents: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NAME | SALES &lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------" /&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Duck | 40 &lt;/P&gt;&lt;P&gt;Tiger | 20 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Addition 1 &lt;/P&gt;&lt;P&gt;... ASSIGNING &amp;lt;fs&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;If this statement is successfully executed, the field symbol &amp;lt;fs&amp;gt; is set to the changed or new entry. Otherwise the field symbol remains unchanged. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Addition 2 &lt;/P&gt;&lt;P&gt;... REFERENCE INTO dref &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;If this statement is successfully executed the reference to the relevant line is placed in dref. Otherwise the data reference dref remains unchanged. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Addition 3 &lt;/P&gt;&lt;P&gt;... SORTED BY f &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;COLLECT ... SORTED BY f is obsolete, and should no longer be used. It only applies to standard tables, and has the same function as APPEND ... SORTED BY f, which you should use instead. (See also Obsolete Language Elements). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note &lt;/P&gt;&lt;P&gt;Performance: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are still using internal tables with headers but, as recommended, keep your data in work areas with a different name, you do not need to assign the data to the header first in order to pass it to the internal tables. Instead, you should use the work area directly as with tables without headers. For example, "APPEND wa TO itab." is roughly twice as fast as "itab = wa. APPEND itab.". The same applies to COLLECT and INSERT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The runtime of a COLLECT increases with the width of the table key and the number of numeric fields whose contents are summated. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exceptions &lt;/P&gt;&lt;P&gt;Catchable Exceptions &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CX_SY_ARITHMETIC_OVERFLOW &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cause: Overflow in the integer field when forming totals &lt;/P&gt;&lt;P&gt;Runtime Error: COLLECT_OVERFLOW &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cause: overflow in type P field when forming totals &lt;/P&gt;&lt;P&gt;Runtime Error: COLLECT_OVERFLOW_TYPE_P &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Non-Catchable Exceptions &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cause: COLLECT on non-numeric fileds &lt;/P&gt;&lt;P&gt;Runtime Error: TABLE_COLLECT_CHAR_IN_FUNCTION &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm" target="test_blank"&gt;http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Priyanka.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 06:50:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547116#M579506</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T06:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: COLLECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547117#M579507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF COMPANIES OCCURS 10,&lt;/P&gt;&lt;P&gt;NAME(20),&lt;/P&gt;&lt;P&gt;SALES TYPE I,&lt;/P&gt;&lt;P&gt;END OF COMPANIES.&lt;/P&gt;&lt;P&gt;COMPANIES-NAME = 'Duck'. COMPANIES-SALES = 10.&lt;/P&gt;&lt;P&gt;COLLECT COMPANIES.&lt;/P&gt;&lt;P&gt;COMPANIES-NAME = 'Tiger'. COMPANIES-SALES = 20.&lt;/P&gt;&lt;P&gt;COLLECT COMPANIES.&lt;/P&gt;&lt;P&gt;COMPANIES-NAME = 'Duck'. COMPANIES-SALES = 30.&lt;/P&gt;&lt;P&gt;COLLECT COMPANIES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table COMPANIES now has the following appearance: &lt;/P&gt;&lt;P&gt;Duck 40&lt;/P&gt;&lt;P&gt;Tiger 20&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the line is inserted, the system checks whether there is already a table entry that matches the key. &lt;/P&gt;&lt;P&gt;If there is no corresponding entry already in the table, &lt;/P&gt;&lt;P&gt;the COLLECT statement has the same effect as inserting the new line. &lt;/P&gt;&lt;P&gt;If an entry with the same key already exists, &lt;/P&gt;&lt;P&gt;the COLLECT statement does not append a new line,&lt;/P&gt;&lt;P&gt;but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entry. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should only use the COLLECT statement if you want to create summarized tables.&lt;/P&gt;&lt;P&gt;If you use other statements to insert table entries, you may end up with duplicate entries.&lt;/P&gt;&lt;P&gt;GO THROUGH THIS LINK&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm" target="test_blank"&gt;http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Can i use a collect statement here&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We can use collect statement in all internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. The only MAIN CONCEPT is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. that it will SUM up the Quantity fields,&lt;/P&gt;&lt;P&gt;based upon &lt;/P&gt;&lt;P&gt;the COMBINATION of all Character Fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 06:51:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547117#M579507</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T06:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: COLLECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547118#M579508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COLLECT is used to create unique or compressed datsets. The key fields are the default key fields of the internal table itab . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If, besides its default key fields, the internal table contains number fields (see also ABAP/4 number types ), the contents of these number fields are added together if the internal table already contains an entry with the same key fields. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the default key of an internal table processed with COLLECT is blank, all the values are added up in the first table line. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you specify wa INTO , the entry to be processed is taken from the explicitly specified work area wa . If not, it comes from the header line of the internal table itab . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After COLLECT , the system field SY-TABIX contains the index of the - existing or new - table entry with default key fields which match those of the entry to be processed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt; Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 06:51:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547118#M579508</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T06:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: COLLECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547119#M579509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In short i would explain liek this,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;suppose your Internal table is like this,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. K 10 20&lt;/P&gt;&lt;P&gt;   K 20 30&lt;/P&gt;&lt;P&gt;   A 10 15&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OutPut:&lt;/P&gt;&lt;P&gt;K 30 50&lt;/P&gt;&lt;P&gt;A 10 15&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. And even if u remove A and K&lt;/P&gt;&lt;P&gt;then&lt;/P&gt;&lt;P&gt;10 20&lt;/P&gt;&lt;P&gt;20 30&lt;/P&gt;&lt;P&gt;10 15&lt;/P&gt;&lt;P&gt;then&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;40 65&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if useful!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 06:54:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547119#M579509</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T06:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: COLLECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547120#M579510</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COLLECT summarizes all numberic fields based on the non-numeric fields contents.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For Example &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Summarized sales figures by company: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF COMPANY, &lt;/P&gt;&lt;P&gt;        NAME(20) TYPE C, &lt;/P&gt;&lt;P&gt;        SALES    TYPE I, &lt;/P&gt;&lt;P&gt;      END OF COMPANY. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;DATA: COMP    TYPE COMPANY, &lt;/P&gt;&lt;P&gt;      COMPTAB TYPE HASHED TABLE OF COMPANY &lt;/P&gt;&lt;P&gt;                                WITH UNIQUE KEY NAME. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;COMP-NAME = 'Duck'.  COMP-SALES = 10. COLLECT COMP INTO COMPTAB. &lt;/P&gt;&lt;P&gt;COMP-NAME = 'Tiger'. COMP-SALES = 20. COLLECT COMP INTO COMPTAB. &lt;/P&gt;&lt;P&gt;COMP-NAME = 'Duck'.  COMP-SALES = 30. COLLECT COMP INTO COMPTAB&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table COMPTAB now has the following contents: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NAME | SALES &lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------" /&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Duck | 40 &lt;/P&gt;&lt;P&gt;Tiger | 20 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, check this thread&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="361888"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2007 06:58:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect/m-p/2547120#M579510</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-17T06:58:43Z</dc:date>
    </item>
  </channel>
</rss>

