<?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 collect statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799896#M1123921</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have got my final internal table with "valuation class" and "Obsollete Value". Now I want to get the total &lt;/P&gt;&lt;P&gt;obsolete value based on valuation class. How to use Collect statement for the same.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Dec 2008 07:42:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-12-02T07:42:44Z</dc:date>
    <item>
      <title>collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799896#M1123921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have got my final internal table with "valuation class" and "Obsollete Value". Now I want to get the total &lt;/P&gt;&lt;P&gt;obsolete value based on valuation class. How to use Collect statement for the same.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Dec 2008 07:42:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799896#M1123921</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-02T07:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799897#M1123922</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;Search SCN. You will get lot of threads on use of collect statement.&lt;/P&gt;&lt;P&gt;Here is one of those:&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="4024941"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nitin.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Dec 2008 07:45:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799897#M1123922</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-02T07:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799898#M1123923</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 can work use it like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at &amp;lt;int_tab&amp;gt; into &amp;lt;wa&amp;gt;&lt;/P&gt;&lt;P&gt;collect &amp;lt;wa&amp;gt; into &amp;lt;int_tab&amp;gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Neha Shukla on Dec 2, 2008 7:51 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Dec 2008 14:18:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799898#M1123923</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-02T14:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799899#M1123924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Instead of collect use the sum it will better .&lt;/P&gt;&lt;P&gt;Collect will sum the all non char fields...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bharani&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Dec 2008 14:25:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799899#M1123924</guid>
      <dc:creator>BH2408</dc:creator>
      <dc:date>2008-12-02T14:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799900#M1123925</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;You can achieve like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: lf_tab1  type &amp;lt;same as itab&amp;gt;,&lt;/P&gt;&lt;P&gt;        lw_tab1 type &amp;lt;line of itab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort itab by class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt; at end of class.&lt;/P&gt;&lt;P&gt;   sum.&lt;/P&gt;&lt;P&gt;   lw_tab1-value = itab-value.&lt;/P&gt;&lt;P&gt;   lw_tab1-class = itab-class.&lt;/P&gt;&lt;P&gt;   append lw_tab1 to itab1.&lt;/P&gt;&lt;P&gt; endat.&lt;/P&gt;&lt;P&gt;endloop.&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, 02 Dec 2008 15:25:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799900#M1123925</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-02T15:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799901#M1123926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;sort itab by aufnr matnr.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      &lt;STRONG&gt;loop at itab.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           &lt;STRONG&gt;at end of matnr.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;           &lt;STRONG&gt;sum.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;           &lt;STRONG&gt;move-corresponding itab to t_charg.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;           &lt;STRONG&gt;collect t_charg.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;           &lt;STRONG&gt;endat.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;      &lt;STRONG&gt;endloop.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2008 06:04:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799901#M1123926</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-03T06:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799902#M1123927</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;actually , next time when you come across the key word issue, what you can do is check the key word help documents:    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write the key word in the abap editor, then place  the cursor on it and press F1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax &lt;/P&gt;&lt;P&gt;COLLECT wa INTO itab [result]. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;This statement inserts the contents of a work area wa either as single row into an internal table itab or adds the values of its numeric components to the corresponding values of existing rows with the same key. As of Release 6.10, you can use result to set a reference to the inserted or changed row in the form of a field symbol or data reference. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prerequisite for the use of this statement is that wa is compatible with the row type of itab and all components that are not part of the table key must have a numeric data type (i, p, f). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In standard tables that are only filled using COLLECT, the entry is determined by a temporarily created hash administration. The workload is independent of the number of entries in the table. The hash administration is temporary and is generally invalidated when the table is accessed for changing. If further COLLECT statements are entered after an invalidation, a linear search of all table rows is performed. The workload for this search increases in a linear fashion in relation to the number of entries. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In sorted tables, the entry is determined using a binary search. The workload has a logarithmic relationship to the number of entries in the table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In hashed tables, the entry is determined using the hash administration of the table and is always independent of the number of table entries. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If no line is found with an identical key, a row is inserted as described below, and filled with the content of wa: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In standard tables the line is appended. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In sorted tables, the new line is inserted in the sort sequence of the internal table according to its key values, and the table index of subsequent rows is increased by 1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In hashed tables, the new row is inserted into the internal table by the hash administration, according to its key values. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the internal table already contains one or more rows with an identical key, those values of the components of work area wa that are not part of the key, are added to the corresponding components of the uppermost existing row (in the case of index tables, this is the row with the lowest table index). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The COLLECT statement sets sy-tabix to the table index of the inserted or existing row, in the case of standard tables and sorted tables, and to the value 0 in the case of hashed tables. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Outside of classes, you can omit wa INTO if the internal table has an identically-named header line itab. The statement then implicitly uses the header line as the work area. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COLLECT should only be used if you want to create an internal table that is genuinely unique or compressed. In this case, COLLECT can greatly benefit performance. If uniqueness or compression are not required, or the uniqueness is guaranteed for other reasons, the INSERT statement should be used instead. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The use of COLLECT for standard tables is obsolete. COLLECT should primarily be used for hashed tables, as these have a unique table key and a stable hash administration. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If a standard table is filled using COLLECT, it should not be edited using any other statement with the exception of MODIFY. If the latter is used with the addition TRANSPORTING, you must ensure that no key fields are changed. This is the only way to guarantee that the table entries are always unique and compressed, and that the COLLECT statement functions correctly and benefits performance. The function module ABL_TABLE_HASH_STATE can be used to check whether a standard table is suitable for editing using COLLECT. &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;Compressed insertion of data from the database table sflight into the internal table seats_tab. The rows in which the key components carrid and connid are identical are compressed by adding the number of occupied seats to the numeric component seatsocc. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: BEGIN OF seats, 
        carrid   TYPE sflight-carrid, 
        connid   TYPE sflight-connid, 
        seatsocc TYPE sflight-seatsocc, 
      END OF seats. 

DATA seats_tab LIKE HASHED TABLE OF seats 
               WITH UNIQUE KEY carrid connid. 

SELECT carrid connid seatsocc 
       FROM sflight 
       INTO seats. 
  COLLECT seats INTO seats_tab. 
ENDSELECT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2008 06:45:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/4799902#M1123927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-03T06:45:40Z</dc:date>
    </item>
  </channel>
</rss>

