<?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 append &amp; collect in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780127#M336270</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what is diff between append and collect ?&lt;/P&gt;&lt;P&gt;Can we use append statement  after using collect statement ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Nov 2006 07:17:33 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-11-30T07:17:33Z</dc:date>
    <item>
      <title>append &amp; collect</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780127#M336270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what is diff between append and collect ?&lt;/P&gt;&lt;P&gt;Can we use append statement  after using collect statement ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2006 07:17:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780127#M336270</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-30T07:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: append &amp; collect</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780128#M336271</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;PRE&gt;&lt;CODE&gt;
DATA: BEGIN OF COMPANIES OCCURS 10,
        NAME(20),
        SALES TYPE I,
      END   OF COMPANIES.
COMPANIES-NAME = 'Duck'.  COMPANIES-SALES = 10.
COLLECT COMPANIES.
COMPANIES-NAME = 'Tiger'. COMPANIES-SALES = 20.
COLLECT COMPANIES.
COMPANIES-NAME = 'Duck'.  COMPANIES-SALES = 30.
COLLECT COMPANIES.&lt;/CODE&gt;&lt;/PRE&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;Anver&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2006 07:19:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780128#M336271</guid>
      <dc:creator>anversha_s</dc:creator>
      <dc:date>2006-11-30T07:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: append &amp; collect</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780129#M336272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;chk this thread&lt;/P&gt;&lt;P&gt;&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="2669853"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2006 07:25:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780129#M336272</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-30T07:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: append &amp; collect</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780130#M336273</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;If an entry with the same key already exists, the COLLECT statement does not append a new line, 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;Append &amp;#150; Duplicate entries occurs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Yamini&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2006 07:58:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780130#M336273</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-30T07:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: append &amp; collect</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780131#M336274</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 create unique or compressed datasets and should be used precisely for this purpose. If uniqueness or compression are unimportant, or two values with identical default key field values could not possibly occur in your particular task, you should use APPEND instead. However, for a unique or compressed dataset which is also efficient, COLLECT is the statement to use. &lt;/P&gt;&lt;P&gt;If you process a table with COLLECT , you should also use COLLECT to fill it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this for more information.&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;No need of using append after collect.&lt;/P&gt;&lt;P&gt;LOOP AT I_LIPS INTO W_LIPS."Calculating total quantity&lt;/P&gt;&lt;P&gt;   W_TOTAL-VBELN = W_LIPS-VBELN.&lt;/P&gt;&lt;P&gt;   W_TOTAL-LFIMG = W_LIPS-LFIMG.&lt;/P&gt;&lt;P&gt;   COLLECT W_TOTAL INTO I_TOTAL .&lt;/P&gt;&lt;P&gt;   CLEAR W_TOTAL.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Jayanthi Jayaraman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2006 08:01:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780131#M336274</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2006-11-30T08:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: append &amp; collect</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780132#M336275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   Collect is used as means for summation of numeric data. When you use collect if there is a record with same 'KEY' as that of your workarea, in the internal table then this workarea's numeric fields will be added to the numeric fields of the record in the internal table with the same KEY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the record does not exist then the record is appended to the internal table. Also you need to see if there is any INITIAL SIZE for the internal table if the number of records will be more than the INITIAL SIZE then some the new record will replace some existing record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should either use COLLECT or APPEND not both.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2006 08:03:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780132#M336275</guid>
      <dc:creator>seshatalpasai_madala</dc:creator>
      <dc:date>2006-11-30T08:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: append &amp; collect</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780133#M336276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Append statement is used to add the data from default header area into body area of an internal table. While adding the records, this statement will not verify whether the record is already existing or not. Even the record already exists... The new record will be added again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Collect statement is also used in Internal table to add header data to the body area. While adding this statement verifies whether the entering record already exists or not? If it founds already, The numeric fields will only get added to the existing record, but not the another duplicate record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex:&lt;/P&gt;&lt;P&gt;Data: begin of itab occurs 1,&lt;/P&gt;&lt;P&gt;eid(10),&lt;/P&gt;&lt;P&gt;ename(20),&lt;/P&gt;&lt;P&gt;sal type i,&lt;/P&gt;&lt;P&gt;end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab-eid = '1001'.&lt;/P&gt;&lt;P&gt;itab-ename = 'abcd'.&lt;/P&gt;&lt;P&gt;itab-sal = '25000'.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;collect itab.&lt;/P&gt;&lt;P&gt;collect itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;write: / itab-eid, itab-ename, itab-sal.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Dec 2006 14:07:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780133#M336276</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-12-05T14:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: append &amp; collect</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780134#M336277</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;The collect 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. You can use result to set a reference to the inserted or changed row in form of a field symbol or data reference. &lt;/P&gt;&lt;P&gt;Append statement inserts the content of the work area into the table without adding the values of its numeric components.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex if ther are four records.&lt;/P&gt;&lt;P&gt;abc   def   xyz  10&lt;/P&gt;&lt;P&gt;abc   def   xyz  15&lt;/P&gt;&lt;P&gt;abc   def   xyz  20&lt;/P&gt;&lt;P&gt;azz   def   xyz  30&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you use append four records will be appended to the internal table &lt;/P&gt;&lt;P&gt;if you use collect only two records will be appended as-&lt;/P&gt;&lt;P&gt;abc   def   xyz  45&lt;/P&gt;&lt;P&gt;azz   def   xyz  30&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this explaination helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Richa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Dec 2006 15:08:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780134#M336277</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-12-05T15:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: append &amp; collect</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780135#M336278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI mahya k,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say suppose an Internal table has a Work area and a Body &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Append --&amp;gt; simply appends/adds the current record u are working on (in the workarea) at the end of the internal table. .... &lt;/P&gt;&lt;P&gt;but collect will check all the fields of that record till the numberic field in the internal table body and just adds the numeral to the numeral of the work area and modifies the internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Internal table = ITAB&lt;/P&gt;&lt;P&gt;Fields = Name, Subject, mark, city&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here Name, subject and city are character fields &lt;/P&gt;&lt;P&gt;and  mark is a numeric field .....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA has --&amp;gt; &lt;/P&gt;&lt;P&gt;AAA MAths 50 City1&lt;/P&gt;&lt;P&gt;Int Body --&amp;gt; &lt;/P&gt;&lt;P&gt;BBB English 40 City2&lt;/P&gt;&lt;P&gt;AAA English 60 City2&lt;/P&gt;&lt;P&gt;CCC Maths 30 City1&lt;/P&gt;&lt;P&gt;AAA Maths 40 City1 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No of records = 4 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Append will result in&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Int body with 5 records &lt;/P&gt;&lt;P&gt;BBB English 40 City2&lt;/P&gt;&lt;P&gt;AAA English 60 City2&lt;/P&gt;&lt;P&gt;CCC Maths 30 City1&lt;/P&gt;&lt;P&gt;AAA Maths 40 City2 &lt;/P&gt;&lt;P&gt;AAA MAths 50 City1   &amp;lt;b&amp;gt;&amp;lt;-- Work area&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Collect will result in&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Int body now contains only 4 records ....&lt;/P&gt;&lt;P&gt;BBB English 40 City2&lt;/P&gt;&lt;P&gt;AAA English 60 City2&lt;/P&gt;&lt;P&gt;CCC Maths 30 City1&lt;/P&gt;&lt;P&gt;AAA Maths &amp;lt;b&amp;gt;90&amp;lt;/b&amp;gt; City2 &amp;lt;b&amp;gt;&amp;lt;-- The numeral got added in the same record &amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: IT will not check for the last character field (which is city)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Kripa Rangachari....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Dec 2006 06:25:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780135#M336278</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-12-06T06:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: append &amp; collect</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780136#M336279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Taken it from help....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;COLLECT&amp;lt;/b&amp;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;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;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;&amp;lt;b&amp;gt;APPEND&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax &lt;/P&gt;&lt;P&gt;APPEND line_spec TO itab [SORTED BY comp] [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;Addition: &lt;/P&gt;&lt;P&gt;... SORTED BY comp &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 appends one or more rows line_spec to an internal index table itab. If itab is a standard table, you can use SORTED BY to sort the table in a specified way. Use result when appending a single row as of release 6.10 to set a reference to the appended row in the form of a field symbol or a data reference. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the individual table types, appending is done as follows: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To standard tables, rows are appended directly and without checking the content of the internal table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To sorted tables, rows are appended only if they correspond to the sort sequence and do not create duplicate entries with unique table key. Otherwise, an untreatable exception is triggered. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To hashed tables, no rows can be appended. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The APPEND statement sets sy-tabix to the table index of the last appended row. &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 &lt;/P&gt;&lt;P&gt;... SORTED BY comp &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 addition is allowed only if you specify a workarea wa and if you use a standard table, where wa must be compatible to the row type of the table. You can specify component comp as shown in section Specifying Components, however, you can access only one single component and no attributes of classes using the object component selector. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The statement is executed in two steps: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Starting at the last row, the table is searched for a row, in which the value of component comp is greater than or equal to the value of component comp of wa. If such a row exists, the workarea wa is included after this row. If no such row exists, the workarea wa is included before the first row. The table index of all rows following the included rows increases by one. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the number of rows before the statement is executed is greater than or equal to the number specified in the definition of the internal table in the INITIAL SIZE addition, the newly-created last row is deleted. &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;When using only the statement APPEND with addition SORTED BY to fill an internal table, this rule results in an internal table that contains no more than the number of rows specified in its definition after INITIAL SIZE and that is sorted in descending order by component comp (ranking). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SORT statement should usually be used instead of APPEND SORTED BY. &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;Creating a ranking of the three flights of a connection showing the most free seats. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS: p_carrid TYPE sflight-carrid, &lt;/P&gt;&lt;P&gt;            p_connid TYPE sflight-connid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF seats, &lt;/P&gt;&lt;P&gt;        fldate TYPE sflight-fldate, &lt;/P&gt;&lt;P&gt;        seatsocc TYPE sflight-seatsocc, &lt;/P&gt;&lt;P&gt;        seatsmax TYPE sflight-seatsmax, &lt;/P&gt;&lt;P&gt;        seatsfree 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 STANDARD TABLE OF seats &lt;/P&gt;&lt;P&gt;               INITIAL SIZE 3. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT fldate seatsocc seatsmax &lt;/P&gt;&lt;P&gt;       FROM sflight &lt;/P&gt;&lt;P&gt;       INTO seats &lt;/P&gt;&lt;P&gt;       WHERE carrid = p_carrid AND &lt;/P&gt;&lt;P&gt;             connid = p_connid. &lt;/P&gt;&lt;P&gt;  seats-seatsfree = seats-seatsmax - seats-seatsocc. &lt;/P&gt;&lt;P&gt;  APPEND seats TO seats_tab SORTED BY seatsfree. &lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Dec 2006 06:38:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/append-collect/m-p/1780136#M336279</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-12-06T06:38:17Z</dc:date>
    </item>
  </channel>
</rss>

