<?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: Condition WHERE in LOOP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338186#M1229781</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&amp;gt; using loop without where and using case can result in more iterations than required so can be performance issue.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;кu03B1ятu03B9к - not really. It will go through the loop exactly once in both cases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 15 Mar 2009 03:29:56 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-03-15T03:29:56Z</dc:date>
    <item>
      <title>Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338183#M1229778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good afternoon,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following issue,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I  have that do a LOOP to a table Internal, ie.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at it_tabla where lgart = '0100' or lgart = '0200' or lgart = '0300' or lgart = '0400' or lgart = '0500' or  lgart = '0600' or lgart = '0700' or lgart = '0800' .&lt;/P&gt;&lt;P&gt;&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;The question is, Is there any way , in the which not have that do many or  in the sentence LOOP?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Mar 2009 23:01:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338183#M1229778</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-14T23:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338184#M1229779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;loop at it_tabla.&lt;/P&gt;&lt;P&gt;case it_tabla-lgart.&lt;/P&gt;&lt;P&gt;when '0100'&lt;/P&gt;&lt;P&gt;   or     '0200'&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;stms&amp;gt;&lt;/P&gt;&lt;P&gt;endcase.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: BrightSide on Mar 14, 2009 11:22 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Mar 2009 23:22:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338184#M1229779</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-14T23:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338185#M1229780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use &lt;/P&gt;&lt;P&gt;loop at it_tabla where lgart in ('0100' , '0200' , '0300' , '0400' , '0500' , '0600' , '0700' , '0800' )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;using loop without where and using case can result in more iterations than required so can be performance issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="16" __jive_macro_name="size"&gt;кu03B1ятu03B9к&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Mar 2009 23:56:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338185#M1229780</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-14T23:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338186#M1229781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&amp;gt; using loop without where and using case can result in more iterations than required so can be performance issue.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;кu03B1ятu03B9к - not really. It will go through the loop exactly once in both cases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Mar 2009 03:29:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338186#M1229781</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-15T03:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338187#M1229782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi rob,&lt;/P&gt;&lt;P&gt;i did not understand why it will loop only once. Can u explain it please.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Mar 2009 05:21:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338187#M1229782</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-15T05:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338188#M1229783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think Rob means that it will go through the &lt;EM&gt;table&lt;/EM&gt; once.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's true for Standard tables.  But as it says in the help on the WHERE clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;While with standard tables all rows of the internal table are checked for the logical expression of the WHERE- addition, with &lt;STRONG&gt;sorted&lt;/STRONG&gt; tables and &lt;STRONG&gt;hash&lt;/STRONG&gt; tables (as of Release 7.0) you can achieve optimized access by checking that at least the beginning part of the table key in sorted tables and the entire table key in hash tables is equal in the logical expression through queries linked with AND. Optimization also takes effect if the logical expression contains other queries linked with AND with arbitrary operators&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case though, the queries are linked with OR - so you still get all rows checked!  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, if it_tabla is a sorted table with key lgart, then you could do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PERFORM read_the_table USING: '0100', '0200',...

FORM read_the_table USING i_lgart TYPE ...

  data: l_tabix TYPE sytabix.

  READ TABLE it_table WITH TABLE KEY lgart =i_lgart TRANSPORTING NO FIELDS.
  l_tabix = sy-tabix.
  LOOP AT it_table FROM l_tabix INTO ls_wa.
    IF ls_wa-lgart NE i_lgart.
      EXIT.
    ENDIF.
    " Do stuff
  ENDLOOP.

ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Mar 2009 06:05:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338188#M1229783</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2009-03-15T06:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338189#M1229784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I will agree with both Rob and Matt. If you process the loop without giving the where and use the concept of a parallel cursor, you will be able to achieve your objective. Moreover, it will be much faster than your where condition. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*sort both tables on the key field (in this case field1)
loop at table1.
  loop at table2 from index v_tabix.
    if table2-field1 ne table1-field1.
      v_tabix = sy-tabix.
      exit.
    endif.
  endloop.
*  your code goes here.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Mar 2009 07:04:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338189#M1229784</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-15T07:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338190#M1229785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i think the above problem is not about nested loops so parallel cursor concept doesnot apply, and if loop inside loop is required, best approch is to use read table inside loop it would be better then even parallel cursor isn't it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="16" __jive_macro_name="size"&gt;кu03B1ятu03B9к&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Mar 2009 07:13:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338190#M1229785</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-15T07:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338191#M1229786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;     Instead of where condition in LOOP and ENDLOOP, while fetching the data from the SAP table give the corresponding values in the WHERE condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM &amp;lt;table&amp;gt; INTO TABLE it_tabla 
                WHERE lgart IN ( '0100', '0200', '0300', '0400', '0500', '0600', '0700', '0800'
                AND " other where conditions from selection screen.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now the internal table has only the values of required lgart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bala Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Mar 2009 07:47:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338191#M1229786</guid>
      <dc:creator>former_member585060</dc:creator>
      <dc:date>2009-03-15T07:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338192#M1229787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You for all.&lt;/P&gt;&lt;P&gt;I tested&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_tabla where lgart in ('0100' , '0200' , '0300' , '0400' , '0500' , '0600' , '0700' , '0800' )&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;But the system show an error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Relational operator "IN" is not supported.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sanew2&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Mar 2009 11:25:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338192#M1229787</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-15T11:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338193#M1229788</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;PRE&gt;&lt;CODE&gt;ranges: gv_vbeln for vbak-vbeln.
gv_vbeln-low = '0000000047'.
gv_vbeln-option = 'EQ'.
gv_vbeln-sign = 'I'.
append gv_vbeln.

gv_vbeln-low = '0000000048'.
gv_vbeln-option = 'EQ'.
gv_vbeln-sign = 'I'.
append gv_vbeln.

*  loop at gt_final where vbeln in ( '0000000047' '0000000048' ).  " Failed
  loop at gt_final where vbeln in gv_vbeln.  " Worked fine
     write: gt_final-vbeln.
  endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Above code will work surely,  try it and let me  know if find any difficulties. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;~Satya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Mar 2009 11:57:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338193#M1229788</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-15T11:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Condition WHERE in LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338194#M1229789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; i think the above problem is not about nested loops so parallel cursor concept doesnot apply, and if loop inside loop is required, best approch is to use read table inside loop it would be better then even parallel cursor isn't it?&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Not sure exactly what the question is, but what I was trying to say that using a bunch of ORs or a single IN will not speed up processing (as Matt said for standard tables only). Each record of the table will be read and evaluated in both cases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Mar 2009 19:12:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/condition-where-in-loop/m-p/5338194#M1229789</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-15T19:12:17Z</dc:date>
    </item>
  </channel>
</rss>

