<?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: how to read the same table twice inside the loop? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401166#M1240866</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;&lt;/P&gt;&lt;P&gt;You can also add a where clause to your second loop, so an if statement is not needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at itab intow wa where field1 = ' 1'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;do stuff&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's better to use read statements though this a faster way of working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Guido Koopmann&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: G. Koopmann on Apr 7, 2009 2:18 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Apr 2009 12:18:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-04-07T12:18:27Z</dc:date>
    <item>
      <title>how to read the same table twice inside the loop?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401162#M1240862</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;i hav loop over ekko.and for 1 record in ekko there are 2 records in mseg i.e 2 movement types bwart....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how to read those two records in the loop ao that i can fill two different fields based on the field bwart...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anyone please help me&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 12:02:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401162#M1240862</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-07T12:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to read the same table twice inside the loop?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401163#M1240863</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;LOOP AT ekko.&lt;/P&gt;&lt;P&gt;  read table it_mseg with key mblnr = ekko-ebeln &lt;/P&gt;&lt;P&gt;                                          bwart = '101'.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;read table it_mseg with key mblnr = ekko-ebeln &lt;/P&gt;&lt;P&gt;                                         bwart = '102'.&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;Hope it helps!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 12:04:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401163#M1240863</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-07T12:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to read the same table twice inside the loop?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401164#M1240864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will have to loop inside loop upto 2 rows and your specified condition....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use parallel cursor technique as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;l_tabix type sy-tabix.
  sort itab1 by &amp;lt;key field&amp;gt;
  sort itab2 by &amp;lt;key field&amp;gt;
  loop at itab1.
    loop at itab2 index l_tabix.
      if (your condition).
      l_tabix = sy-tabix.
        * your code here for the conditon.
      else.
      exit.
    endif.
  endloop.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The concept of parallel cursor is to reduce the execution time of the second loop.&lt;/P&gt;&lt;P&gt;This is achieved by starting the second loop from the index for which the last condition is satisfied.&lt;/P&gt;&lt;P&gt;The prerequisite for this is that the tables should be sorted in same order.&lt;/P&gt;&lt;P&gt;Also the condition should be set proper in the loop so that all data is populated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lalit Mohan Gupta.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 12:07:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401164#M1240864</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-07T12:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to read the same table twice inside the loop?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401165#M1240865</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;Loop at  itab_ekko.&lt;/P&gt;&lt;P&gt;READ table itab_mseg with key BWART = x.&lt;/P&gt;&lt;P&gt;if sy-subrc eq  0.&lt;/P&gt;&lt;P&gt;statements to modify the itab_mseg&lt;/P&gt;&lt;P&gt; Endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ table itab_mseg with key BWART = y.&lt;/P&gt;&lt;P&gt;if sy-subrc eq  0.&lt;/P&gt;&lt;P&gt;statements to modify the itab_mseg&lt;/P&gt;&lt;P&gt;Endif.&lt;/P&gt;&lt;P&gt;Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;using loop inside a loop will cause performance issue at times, so better use Read statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: jeevitha krishnaraj on Apr 7, 2009 2:16 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 12:12:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401165#M1240865</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-07T12:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to read the same table twice inside the loop?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401166#M1240866</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;&lt;/P&gt;&lt;P&gt;You can also add a where clause to your second loop, so an if statement is not needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at itab intow wa where field1 = ' 1'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;do stuff&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's better to use read statements though this a faster way of working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Guido Koopmann&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: G. Koopmann on Apr 7, 2009 2:18 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 12:18:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401166#M1240866</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-07T12:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to read the same table twice inside the loop?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401167#M1240867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi dear,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use loop into loop with specific condion.&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at ekko into wa_ekko.&lt;/P&gt;&lt;P&gt;   loop at mseg into wa_mseg where mblnr = wa_ekko-ebeln.&lt;/P&gt;&lt;P&gt;if wa_mseg-bwart = '101'.&lt;/P&gt;&lt;P&gt;   move table.&lt;/P&gt;&lt;P&gt;elseif wa_mseg-bwart = '102'&lt;/P&gt;&lt;P&gt;    move table.&lt;/P&gt;&lt;P&gt;endloop. &lt;/P&gt;&lt;P&gt;append internal table.&lt;/P&gt;&lt;P&gt;clear : wa_ekko, wa_mseg.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this is usefull for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 12:59:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401167#M1240867</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-07T12:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to read the same table twice inside the loop?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401168#M1240868</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 hav used the code as below&lt;/P&gt;&lt;P&gt;LOOP AT it_ekKo ASSIGNING &amp;lt;fs_ekKo&amp;gt;.&lt;/P&gt;&lt;P&gt;READ TABLE it_mseg ASSIGNING &amp;lt;fs_mseg&amp;gt;&lt;/P&gt;&lt;P&gt;                       WITH KEY bwart = c_101&lt;/P&gt;&lt;P&gt;                                matnr = &amp;lt;fs_ekko&amp;gt;-matnr&lt;/P&gt;&lt;P&gt;                                werks = &amp;lt;fs_ekko&amp;gt;-werks&lt;/P&gt;&lt;P&gt;                                ebeln = &amp;lt;fs_ekko&amp;gt;-ebeln&lt;/P&gt;&lt;P&gt;                                ebelp = &amp;lt;fs_ekko&amp;gt;-ebelp&lt;/P&gt;&lt;P&gt;                       BINARY SEARCH.&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt; wa_final-migo_qty = &amp;lt;fs_mseg&amp;gt;-menge.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;READ TABLE it_mseg ASSIGNING &amp;lt;fs_mseg&amp;gt;&lt;/P&gt;&lt;P&gt;                       WITH KEY bwart = c_101&lt;/P&gt;&lt;P&gt;                                matnr = &amp;lt;fs_ekko&amp;gt;-matnr&lt;/P&gt;&lt;P&gt;                                werks = &amp;lt;fs_ekko&amp;gt;-werks&lt;/P&gt;&lt;P&gt;                                ebeln = &amp;lt;fs_ekko&amp;gt;-ebeln&lt;/P&gt;&lt;P&gt;                                ebelp = &amp;lt;fs_ekko&amp;gt;-ebelp&lt;/P&gt;&lt;P&gt;                       BINARY SEARCH.&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt; wa_final-isu_qty = &amp;lt;fs_mseg&amp;gt;-menge.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;but the first read it is doing whereas the control is not going to 2nd read.........&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Apr 2009 06:59:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-read-the-same-table-twice-inside-the-loop/m-p/5401168#M1240868</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-08T06:59:49Z</dc:date>
    </item>
  </channel>
</rss>

