<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ABAP Tutorials &#187; loop</title>
	<atom:link href="http://www.abap-tutorials.com/tag/loop/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.abap-tutorials.com</link>
	<description>ABAP Tutorials, Guides, Training, Manuals</description>
	<lastBuildDate>Thu, 17 Nov 2011 07:43:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>LOOP AT WHERE.   Vs     LOOP.IF.    in ABAP</title>
		<link>http://www.abap-tutorials.com/2009/07/16/loop-at-where-vs-loop-if/</link>
		<comments>http://www.abap-tutorials.com/2009/07/16/loop-at-where-vs-loop-if/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 02:04:00 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[ABAP]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[difference between]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[where]]></category>

		<guid isPermaLink="false">http://naveenvishal.wordpress.com/?p=149</guid>
		<description><![CDATA[At first sight, both the statements ( loop at itab where &#60;key&#62; = &#60;val&#62; ;   loop at itab. if &#60;key&#62; = &#60;val&#62;. ) looks like performing the same task. But when it comes to performance, both beats each other in there own domain. It all comes down to number of &#8220;&#8216;matches&#8221; in the WHERE/IF-clause. In case [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">At first sight, both the statements ( loop at itab where &lt;key&gt; = &lt;val&gt; ;   loop at itab. if &lt;key&gt; = &lt;val&gt;. ) looks like performing the same task.</p>
<p style="text-align:justify;">But when it comes to performance, both beats each other in there own domain.</p>
<p style="text-align:justify;"><span id="more-149"></span></p>
<p style="text-align:justify;">It all comes down to number of &#8220;&#8216;matches&#8221; in the WHERE/IF-clause.</p>
<p style="text-align:justify;">In case you have a rare match, the WHERE-method is better.<br />
In case you have an always match, the IF-method is better.</p>
<p style="text-align:justify;">When the match was done on<strong> 1-out-1000</strong>:</p>
<div class="mceTemp mceIEcenter" style="text-align:justify;">
<dl class="wp-caption aligncenter">
<dt class="wp-caption-dt"><img class="size-medium wp-image-150" title="loopatwhereif" src="http://naveenvishal.files.wordpress.com/2009/07/loopatwhereif.jpg?w=300" alt="match ratio: 1 - out of - 1000" width="300" height="269" /></dt>
<dd class="wp-caption-dd">match ratio: 1 &#8211; out of &#8211; 1000</dd>
</dl>
</div>
<p style="text-align:justify;">When the match was done at <strong>1 &#8211; out of -2 </strong>:</p>
<div class="mceTemp mceIEcenter" style="text-align:justify;">
<dl class="wp-caption aligncenter">
<dt class="wp-caption-dt"><img class="size-medium wp-image-151" title="loopatwhereif2" src="http://naveenvishal.files.wordpress.com/2009/07/loopatwhereif2.jpg?w=300" alt="match ratio: 1 - out of - 2" width="300" height="270" /></dt>
<dd class="wp-caption-dd">match ratio: 1 &#8211; out of &#8211; 2</dd>
</dl>
</div>
<p style="text-align:justify;">and when the &#8220;match&#8221; is <strong>matching every line</strong></p>
<div class="mceTemp mceIEcenter" style="text-align:justify;">
<dl class="wp-caption aligncenter">
<dt class="wp-caption-dt"><img class="size-medium wp-image-152" title="loopatwhereif3" src="http://naveenvishal.files.wordpress.com/2009/07/loopatwhereif3.jpg?w=300" alt="Match ratio : matching every line " width="300" height="267" /></dt>
<dd class="wp-caption-dd">Match ratio : matching every line </dd>
</dl>
</div>
<p style="text-align:justify;"> </p>
<p style="text-align:justify;">*source = Harry Dietz</p>


<p>You might also be interested in these posts:<ol><li><a href='http://www.abap-tutorials.com/2009/07/11/best-way-to-loop-at-standard-internal-table/' rel='bookmark' title='Best way to Loop At &#8216;Standard&#8217; Internal Table in ABAP'>Best way to Loop At &#8216;Standard&#8217; Internal Table in ABAP</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/15/my-inactive-programs/' rel='bookmark' title='ABAP Program to show My Inactive Programs'>ABAP Program to show My Inactive Programs</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/18/create-a-tcode-for-an-abap-query/' rel='bookmark' title='Create a TCODE for an ABAP Query'>Create a TCODE for an ABAP Query</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.abap-tutorials.com/2009/07/16/loop-at-where-vs-loop-if/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Best way to Loop At &#8216;Standard&#8217; Internal Table in ABAP</title>
		<link>http://www.abap-tutorials.com/2009/07/11/best-way-to-loop-at-standard-internal-table/</link>
		<comments>http://www.abap-tutorials.com/2009/07/11/best-way-to-loop-at-standard-internal-table/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 02:40:18 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[ABAP]]></category>
		<category><![CDATA[Sample Code]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[best way]]></category>
		<category><![CDATA[internal table]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[loop at]]></category>
		<category><![CDATA[SAP]]></category>

		<guid isPermaLink="false">http://naveenvishal.wordpress.com/?p=95</guid>
		<description><![CDATA[When it comes to looping thru a standard Internal Table, almost every ABAPer normally loops like this (I_COEP is already sorted) (1) Loop at I_COEP where kokrs = i_cobk-kokrs and belnr = i_cobk-belnr. &#8230;&#8230; endloop. And this the SLOWEST method to be adopted. The next best method is accessing the right set of data, using Binary Search, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">When it comes to looping thru a standard Internal Table, almost every ABAPer normally loops like this (I_COEP is already sorted)<br />
(1) Loop at I_COEP where kokrs = i_cobk-kokrs<br />
and belnr = i_cobk-belnr.<br />
&#8230;&#8230;<br />
endloop.</p>
<p style="text-align:justify;">And this the SLOWEST method to be adopted.</p>
<p style="text-align:justify;"><span id="more-95"></span></p>
<p style="text-align:justify;">The next best method is accessing the right set of data, using Binary Search, and then read thru it.</p>
<p style="text-align:justify;">(2) read table i_coep with key<br />
kokrs = i_cobk-kokrs<br />
belnr = i_cobk-belnr<br />
binary search.<br />
if sy-subrc = 0.<br />
Loop at i_coep from sy-tabix<br />
where kokrs = i_cobk-kokrs<br />
and belnr = i_cobk-belnr.<br />
&#8230;&#8230;.<br />
Endloop.<br />
endif.</p>
<p style="text-align:justify;">But &#8216;the best of the lot&#8217; goes to the code, which is the extension of second method defined above. This code exits when no matching criteria is found and thus avoid looping thru the whole internal table.</p>
<p style="text-align:justify;">(3) read table i_coep with key<br />
kokrs = i_cobk-kokrs<br />
belnr = i_cobk-belnr<br />
binary search.<br />
if sy-subrc = 0.<br />
Loop at i_coep from sy-tabix.<br />
if ( i_coep-kokrs NE i_cobk-kokrs or<br />
i_coep-belnr NE i_cobk-belnr )<br />
exit.<br />
endif.<br />
Endloop.<br />
endif.</p>


<p>You might also be interested in these posts:<ol><li><a href='http://www.abap-tutorials.com/2009/07/16/loop-at-where-vs-loop-if/' rel='bookmark' title='LOOP AT WHERE.   Vs     LOOP.IF.    in ABAP'>LOOP AT WHERE.   Vs     LOOP.IF.    in ABAP</a></li>
<li><a href='http://www.abap-tutorials.com/2011/08/06/upload-file-from-application-server-into-abap-internal-table-in-sa/' rel='bookmark' title='Upload File from Application Server into ABAP Internal Table in SAP'>Upload File from Application Server into ABAP Internal Table in SAP</a></li>
<li><a href='http://www.abap-tutorials.com/2009/09/16/abap-program-for-table-maintenance-in-sap/' rel='bookmark' title='ABAP Program for Table Maintenance in SAP'>ABAP Program for Table Maintenance in SAP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.abap-tutorials.com/2009/07/11/best-way-to-loop-at-standard-internal-table/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

