<?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: problem in collect statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-collect-statement/m-p/2222703#M477388</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;lt;b&amp;gt;You will get the desired output below:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  Z_82235_TEST4                           .

types: begin of t_ab,
        no(2) type c,
        name(5) type c,
        amt type i,
       end of t_ab.

data: itab type table of t_ab,
      wa like line of itab.

wa-no = '11'.
wa-name = 'name1'.
wa-amt = 23.

append wa to itab.
clear : wa.

wa-no = '22'.
wa-name = 'name2'.
wa-amt = 1324.

COLLECT wa INTO itab.
clear : wa.

wa-no = '11'.
wa-name = 'name1'.
wa-amt = 10.

COLLECT wa INTO itab.
clear : wa.

loop at itab into wa.
write: / wa-no, wa-name, wa-amt.
clear wa.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 28 Apr 2007 05:34:49 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-04-28T05:34:49Z</dc:date>
    <item>
      <title>problem in collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-collect-statement/m-p/2222700#M477385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i have requirement to get all unique entries from table .if i am getting duplicate record then i need to add qunatity field which i have define like rlbes-anfme.&lt;/P&gt;&lt;P&gt;my internal table is :&lt;/P&gt;&lt;P&gt;11 name1 23.00&lt;/P&gt;&lt;P&gt;22 name2 1,324.00&lt;/P&gt;&lt;P&gt;11 name1 10.00&lt;/P&gt;&lt;P&gt;I want output in this way&lt;/P&gt;&lt;P&gt;11 name1  33.00&lt;/P&gt;&lt;P&gt;22 name2 1,324.00&lt;/P&gt;&lt;P&gt;i tried to use collect statement but the problem is its not working on character type field.&lt;/P&gt;&lt;P&gt;if  i use packed field then i am not able to upload my file because i am getting quantity filed 1,2344.00 this way.( instead of 1325.00)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please give me any solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;jack&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2007 22:11:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-collect-statement/m-p/2222700#M477385</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-27T22:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: problem in collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-collect-statement/m-p/2222701#M477386</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;Try this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create another internal table which has the same structure of your internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: LT_COLLECT LIKE ITAB OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA: V_QUANTITY TYPE MENGE_D.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Sort the internal table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SORT ITAB BY field1 field2.    " Give the appropriate field names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;* process the internal table which has the records.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Sum up the quantity.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   V_MENGE = V_MENGE + ITAB-ANFME.  " Quantity field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Move the first two fields.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   LT_COLLECT-FIELD1 = ITAB-FIELD1.  &lt;/P&gt;&lt;P&gt;   LT_COLLECT-FIELD2 = ITAB-FIELD2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;At the end of the record..append the record.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   AT END OF FIELD2.     " Give the corresponding field name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      LT_COLLECT-ANFME = V_MENGE.&lt;/P&gt;&lt;P&gt;      APPEND LT_COLLECT. &lt;/P&gt;&lt;P&gt;     &lt;/P&gt;&lt;P&gt;     CLEAR: V_MENGE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   ENDAT.   &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Naren&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2007 22:58:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-collect-statement/m-p/2222701#M477386</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-27T22:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: problem in collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-collect-statement/m-p/2222702#M477387</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;Try the below code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your internal table the datatype must be Character for all the fields inorder to upload successfully. Create another internal table,say it_collect, which has the same structure of your internal table but the datatype of quantity field must be like rlbes-anfme and for other fields it must be Character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Loop through your uploaded internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Move the fields to it_collect&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;IT_COLLECT-FIELD1 = ITAB-FIELD1. &lt;/P&gt;&lt;P&gt;IT_COLLECT-FIELD2 = ITAB-FIELD2.&lt;/P&gt;&lt;P&gt;IT_COLLECT-FIELD3 = ITAB-FIELD3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COLLECT IT_COLLECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now your collect statement will work perfectly. The criteria for using Collect statement is in order to sum up quantity fields then all other fields must be Character datatype.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;sksingh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Apr 2007 04:23:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-collect-statement/m-p/2222702#M477387</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-28T04:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: problem in collect statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-collect-statement/m-p/2222703#M477388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;lt;b&amp;gt;You will get the desired output below:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  Z_82235_TEST4                           .

types: begin of t_ab,
        no(2) type c,
        name(5) type c,
        amt type i,
       end of t_ab.

data: itab type table of t_ab,
      wa like line of itab.

wa-no = '11'.
wa-name = 'name1'.
wa-amt = 23.

append wa to itab.
clear : wa.

wa-no = '22'.
wa-name = 'name2'.
wa-amt = 1324.

COLLECT wa INTO itab.
clear : wa.

wa-no = '11'.
wa-name = 'name1'.
wa-amt = 10.

COLLECT wa INTO itab.
clear : wa.

loop at itab into wa.
write: / wa-no, wa-name, wa-amt.
clear wa.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Apr 2007 05:34:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-collect-statement/m-p/2222703#M477388</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-28T05:34:49Z</dc:date>
    </item>
  </channel>
</rss>

