<?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 statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660175#M881616</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;Please note that my struct doesnt hav all the fields of the table..So in this case how will my collect look like&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Apr 2008 05:44:26 GMT</pubDate>
    <dc:creator>GayathriRR</dc:creator>
    <dc:date>2008-04-21T05:44:26Z</dc:date>
    <item>
      <title>Collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660169#M881610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi sap gurus,&lt;/P&gt;&lt;P&gt;I have a table with fields:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A	B	C	D	E&lt;/P&gt;&lt;P&gt;Row1	10	X	30	Y&lt;/P&gt;&lt;P&gt;Row1	10	X	15	Y&lt;/P&gt;&lt;P&gt;Row2	14	2	2	2&lt;/P&gt;&lt;P&gt;Row3	1	1	1	1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a struc with fields A B D.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i want to compress this table based on this struc.&lt;/P&gt;&lt;P&gt;So that my final output is:&lt;/P&gt;&lt;P&gt;A	B	C	D	E&lt;/P&gt;&lt;P&gt;Row1	20	X	45	Y&lt;/P&gt;&lt;P&gt;Row2	14	2	2	2&lt;/P&gt;&lt;P&gt;Row3	1	1	1	1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 04:17:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660169#M881610</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T04:17: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/3660170#M881611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;just loop at ur table that is with entries and at end of  A use collect atatement to sum up all the quantity fields or u can also sum alll the fields in at end of  - endat  and then transfer them to ur new structure&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if helpful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 04:21:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660170#M881611</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T04:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: Collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660171#M881612</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;  Use collect statement...See the example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF LINE,&lt;/P&gt;&lt;P&gt;        COL1(3) TYPE C,&lt;/P&gt;&lt;P&gt;        COL2(2) TYPE N,&lt;/P&gt;&lt;P&gt;        COL3    TYPE I,&lt;/P&gt;&lt;P&gt;      END OF LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA ITAB LIKE SORTED TABLE OF LINE &lt;/P&gt;&lt;P&gt;          WITH NON-UNIQUE KEY COL1 COL2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LINE-COL1 = 'abc'. LINE-COL2 = '12'. LINE-COL3 = 3.&lt;/P&gt;&lt;P&gt;COLLECT LINE INTO ITAB.&lt;/P&gt;&lt;P&gt;WRITE / SY-TABIX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LINE-COL1 = 'def'. LINE-COL2 = '34'. LINE-COL3 = 5.&lt;/P&gt;&lt;P&gt;COLLECT LINE INTO ITAB.&lt;/P&gt;&lt;P&gt;WRITE / SY-TABIX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LINE-COL1 = 'abc'. LINE-COL2 = '12'. LINE-COL3 = 7.&lt;/P&gt;&lt;P&gt;COLLECT LINE INTO ITAB.&lt;/P&gt;&lt;P&gt;WRITE / SY-TABIX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB INTO LINE.&lt;/P&gt;&lt;P&gt;  WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls. reward if useful....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 04:24:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660171#M881612</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T04:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660172#M881613</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;do this way ..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
sort itab by a.
loop at itab.
 collect itab. 
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 04:24:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660172#M881613</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-21T04:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660173#M881614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Collect:&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. If there is no corresponding entry already in the table, the COLLECT statement has the same effect as inserting the new line. 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;You should only use the COLLECT statement if you want to create summarized tables. If you use other statements to insert table entries, you may end up with duplicate entries.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 05:06:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660173#M881614</guid>
      <dc:creator>radhushankar</dc:creator>
      <dc:date>2008-04-21T05:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660174#M881615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;try this..&lt;/P&gt;&lt;P&gt;Note that field B and D in itab have to of type I or P.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab.
  COLLECT itab INTO itab_new.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 05:23:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660174#M881615</guid>
      <dc:creator>asik_shameem</dc:creator>
      <dc:date>2008-04-21T05:23: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/3660175#M881616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;Please note that my struct doesnt hav all the fields of the table..So in this case how will my collect look like&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 05:44:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660175#M881616</guid>
      <dc:creator>GayathriRR</dc:creator>
      <dc:date>2008-04-21T05:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660176#M881617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="blue" __jive_macro_name="color"&gt;
Gayathri,

Check the program. It givs the way u expected.
&lt;PRE&gt;&lt;CODE&gt;

REPORT zvenkat_notepad.

DATA:
      BEGIN OF itab OCCURS 0,
        a TYPE char10,
        b TYPE i,
        c TYPE char2,
        d TYPE i,
        e TYPE char2,
      END OF itab,
      BEGIN OF w_data,
        a TYPE char10,
        b TYPE i,
        d TYPE i,
      END OF w_data.

START-OF-SELECTION.

  w_data-a = 'row1'.
  w_data-b = 10.
  w_data-d = 30.
  MOVE-CORRESPONDING w_data TO itab.
  itab-c = 'X'.
  itab-e = 'Y'.
  COLLECT itab.
  CLEAR  itab.

  w_data-a = 'row1'.
  w_data-b = 10.
  w_data-d = 15.
  MOVE-CORRESPONDING w_data TO itab.
  itab-c = 'X'.
  itab-e = 'Y'.
  COLLECT itab.
  CLEAR  itab.

  w_data-a = 'row2'.
  w_data-b = 14.
  w_data-d = 2.
  MOVE-CORRESPONDING w_data TO itab.
  itab-c = '2'.
  itab-e = '2'.
  COLLECT itab.
  CLEAR  itab.

  w_data-a = 'row3'.
  w_data-b = 1.
  w_data-d = 1.
  MOVE-CORRESPONDING w_data TO itab.
  itab-c = '1'.
  itab-e = '1'.
  COLLECT itab.
  CLEAR  itab.

  LOOP AT itab .
    WRITE: / itab-a,
            itab-b,
            itab-c,
            itab-d,
            itab-e.
  ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;


I hope that it solves ur problem.

Regards,
Venkat.O
&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 06:28:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-statement/m-p/3660176#M881617</guid>
      <dc:creator>venkat_o</dc:creator>
      <dc:date>2008-04-21T06:28:01Z</dc:date>
    </item>
  </channel>
</rss>

