<?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: Query on Internal Table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302619#M1222931</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;Test the following Sample Code this time it will solve out your problem. use &lt;STRONG&gt;MOVE-CORRESPONDING&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: BEGIN OF it OCCURS 10,
  m(10),
  amount1 TYPE i,
  amount2 TYPE i,
  END OF it.

DATA: BEGIN OF it_final OCCURS 10,
  m(10),
  amount1 TYPE i,
  END OF it_final.

it-m = 'AAA'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'AAA'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'BBB'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'AAA'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'BBB'. it-amount1 = 10. it-amount2 = 20. APPEND it.

SORT it BY m.

LOOP AT it into it.
  MOVE-CORRESPONDING it to it_final.
  COLLECT it_final into it_final.
ENDLOOP.

LOOP AT it_final.
  WRITE: / it_final-m, it_final-amount1.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please Reply if any Issue,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Faisal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 07 Mar 2009 11:21:47 GMT</pubDate>
    <dc:creator>faisalatsap</dc:creator>
    <dc:date>2009-03-07T11:21:47Z</dc:date>
    <item>
      <title>Query on Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302612#M1222924</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;               My ITAB looks like below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PN      SN        MATNR     BRGEW    VOLUM    
1         11           D1           100             10
1         11           D1           150             25  
1         11           D2            50              10
2         11           F1           100             10
2         11           F2           150             25  
2         11           F2            50              10    
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My requirement is for same PN &amp;amp; SN if MATNR is same ADD BRGEW and VOLUM along with the details of PN SN MATNR BRGEW VOLUM and store it in another internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My final Table should look like below&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PN      SN        MATNR     BRGEW    VOLUM    
1         11           D1           250             35
1         11           D2            50              10
2         11           F1           100             10
2         11           F2           200             35  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in Advance,&lt;/P&gt;&lt;P&gt;Prasad.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2009 10:22:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302612#M1222924</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-07T10:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302613#M1222925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Collect&lt;/STRONG&gt; Statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Itab ---&amp;gt;Key Fields --&amp;gt; PN ,SN, MATNR(Declare these as key Fileds of itab)
Itab2

Sort itab.
Loop at Itab.
Collect Itab to Itab1.
Endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ITAB1 Will give you required output.&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;Gurpreet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2009 10:24:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302613#M1222925</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-07T10:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302614#M1222926</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;Test the following Sample Code Hope will Help you to solve out your problem,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: BEGIN OF it OCCURS 10,
  m(10),
  amount1 TYPE i,
  amount2 TYPE i,
  END OF it.

DATA: it_final LIKE STANDARD TABLE OF it WITH HEADER LINE.

it-m = 'AAA'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'AAA'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'BBB'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'AAA'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'BBB'. it-amount1 = 10. it-amount2 = 20. APPEND it.

LOOP AT it.
  COLLECT it INTO it_final.
ENDLOOP.

LOOP AT it_final.
  WRITE: / it_final-m, it_final-amount1, it_final-amount2.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please Reply if any Issue,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Faisal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2009 10:31:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302614#M1222926</guid>
      <dc:creator>faisalatsap</dc:creator>
      <dc:date>2009-03-07T10:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302615#M1222927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;look at this example....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT  ztest       .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of itab occurs 0,&lt;/P&gt;&lt;P&gt;      i type i,&lt;/P&gt;&lt;P&gt;      j type i,&lt;/P&gt;&lt;P&gt;      k type i,&lt;/P&gt;&lt;P&gt;      end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of itab1 occurs 0,&lt;/P&gt;&lt;P&gt;      k type i,&lt;/P&gt;&lt;P&gt;      end of itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab-i = 1.&lt;/P&gt;&lt;P&gt;itab-j = 1.&lt;/P&gt;&lt;P&gt;itab-k = 2.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab-i = 1.&lt;/P&gt;&lt;P&gt;itab-j = 1.&lt;/P&gt;&lt;P&gt;itab-k = 4.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab-i = 1.&lt;/P&gt;&lt;P&gt;itab-j = 2.&lt;/P&gt;&lt;P&gt;itab-k = 6.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab-i = 1.&lt;/P&gt;&lt;P&gt;itab-j = 3.&lt;/P&gt;&lt;P&gt;itab-k = 8.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab .&lt;/P&gt;&lt;P&gt;if itab-i = itab-j.&lt;/P&gt;&lt;P&gt;itab1-k = itab-k.&lt;/P&gt;&lt;P&gt;append itab1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;write:/ itab-i, itab-j, itab-k.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;uline.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab1.&lt;/P&gt;&lt;P&gt;write:/ itab1-k.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2009 10:34:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302615#M1222927</guid>
      <dc:creator>former_member203501</dc:creator>
      <dc:date>2009-03-07T10:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302616#M1222928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Guys can you give it in brief.&lt;/P&gt;&lt;P&gt;My Internal tables have work area.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Prasad.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2009 11:07:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302616#M1222928</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-07T11:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302617#M1222929</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;Test the following code here i am using Work Area in fact when you create internal table with OCCURS it automatically create an Work Area with the Same name as internal table and when you use WITH HEADER LINE it do the same, you can't do loop on internal table with out work area.&lt;/P&gt;&lt;P&gt;Let me know if any problem,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT it into wa_it_final.
  COLLECT wa_it_final into it_final.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Faisal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2009 11:13:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302617#M1222929</guid>
      <dc:creator>faisalatsap</dc:creator>
      <dc:date>2009-03-07T11:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302618#M1222930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Faisal ,&lt;/P&gt;&lt;P&gt;               My problem here is &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT it into wa_it_final.
  COLLECT wa_it_final into it_final.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my  wa_it_final has 4 fileds.&lt;/P&gt;&lt;P&gt;But my It_final has 3 fileds.&lt;/P&gt;&lt;P&gt;Its saying that the work area and the Internal table is incompatible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to do this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2009 11:17:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302618#M1222930</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-07T11:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302619#M1222931</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;Test the following Sample Code this time it will solve out your problem. use &lt;STRONG&gt;MOVE-CORRESPONDING&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: BEGIN OF it OCCURS 10,
  m(10),
  amount1 TYPE i,
  amount2 TYPE i,
  END OF it.

DATA: BEGIN OF it_final OCCURS 10,
  m(10),
  amount1 TYPE i,
  END OF it_final.

it-m = 'AAA'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'AAA'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'BBB'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'AAA'. it-amount1 = 10. it-amount2 = 20. APPEND it.
it-m = 'BBB'. it-amount1 = 10. it-amount2 = 20. APPEND it.

SORT it BY m.

LOOP AT it into it.
  MOVE-CORRESPONDING it to it_final.
  COLLECT it_final into it_final.
ENDLOOP.

LOOP AT it_final.
  WRITE: / it_final-m, it_final-amount1.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please Reply if any Issue,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Faisal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2009 11:21:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302619#M1222931</guid>
      <dc:creator>faisalatsap</dc:creator>
      <dc:date>2009-03-07T11:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302620#M1222932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Dheeru&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the WorkArea of 4 field when do loop and inside the loop body MOVE-CORRESPONDING field of 4 Field workarea to 3 Field work area remember one think that the final table where you are going to collect the Values must be of 3 Field like your WorkArea of 3 Field,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Waiting for your Reply,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Faisal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2009 11:28:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302620#M1222932</guid>
      <dc:creator>faisalatsap</dc:creator>
      <dc:date>2009-03-07T11:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302621#M1222933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Thanks a Ton Faisal.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My issue is resolved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Points awarded.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2009 11:47:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-on-internal-table/m-p/5302621#M1222933</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-07T11:47:32Z</dc:date>
    </item>
  </channel>
</rss>

