<?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 Where Condition while Looping in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872513#M673978</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 am not sure if we should use the check on sy-subrc = 4 check inside the loop...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;imagine we need to check for a field called 'Field'.............----&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the purpose of ....loop at internal table where Field = 'X' &lt;/P&gt;&lt;P&gt;is that only records with 'X' should come in the loop..what i believe is that since there are no records it just exits to the endloop..it will not bother to go inside &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you really need to check the case where field &amp;lt;&amp;gt; 'X'&lt;/P&gt;&lt;P&gt;it is better to write&lt;/P&gt;&lt;P&gt;loop at internal table&lt;/P&gt;&lt;P&gt;if field = 'X'.&lt;/P&gt;&lt;P&gt;write : / 'Logic'.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;write : / 'Something'.&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;the best option is to put a break point and see if the code in the loop is being accessed even when the condition is not satisfied..in this way we can have a clear picture&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls check,revert and reward if helpful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Byju&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Oct 2007 07:32:22 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-02T07:32:22Z</dc:date>
    <item>
      <title>Problem in Where Condition while Looping</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872509#M673974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey! experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question to all of you out there? Is it possible to give dynamic where condition while looping an internal table. As for example i have got some code here i have check in debugger all the internal table contain values. Just go through the code and please help me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF struct,&lt;/P&gt;&lt;P&gt;        pernr TYPE persno,&lt;/P&gt;&lt;P&gt;        begda TYPE begda,&lt;/P&gt;&lt;P&gt;        END OF struct.&lt;/P&gt;&lt;P&gt;DATA it_struct TYPE TABLE OF struct.&lt;/P&gt;&lt;P&gt;DATA wa_struct TYPE struct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF temp,&lt;/P&gt;&lt;P&gt;        pernr TYPE persno,&lt;/P&gt;&lt;P&gt;        begda TYPE begda,&lt;/P&gt;&lt;P&gt;        END OF temp.&lt;/P&gt;&lt;P&gt;DATA wa_temp TYPE temp.&lt;/P&gt;&lt;P&gt;DATA it_temp TYPE TABLE OF temp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA it_hrp1001 TYPE TABLE OF hrp1001.&lt;/P&gt;&lt;P&gt;DATA wa_hrp1001 TYPE hrp1001.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA it_hrp1001_chk TYPE TABLE OF hrp1001.&lt;/P&gt;&lt;P&gt;DATA wa_hrp1001_chk TYPE hrp1001.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA lv_hrobjid TYPE hrobjid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a~pernr o~begda INTO CORRESPONDING FIELDS OF TABLE it_struct FROM pa0000 AS a INNER JOIN pa0001 AS o&lt;/P&gt;&lt;P&gt;                                                          ON a~pernr = o~pernr&lt;/P&gt;&lt;P&gt;                                                          WHERE o~endda = '99991231' AND a~stat2 = '3' AND o~pernr = '128'. " and O~BUKRS = 'ETPL'.&lt;/P&gt;&lt;P&gt;SORT it_struct ASCENDING BY pernr.&lt;/P&gt;&lt;P&gt;DELETE ADJACENT DUPLICATES FROM it_struct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM hrp1001 INTO TABLE it_hrp1001 WHERE plvar = '01' AND&lt;/P&gt;&lt;P&gt;                                                  otype = 'P' AND&lt;/P&gt;&lt;P&gt;                                                  rsign = 'A' AND&lt;/P&gt;&lt;P&gt;                                                  relat = '046' AND&lt;/P&gt;&lt;P&gt;                                                  sclas = 'BA' AND&lt;/P&gt;&lt;P&gt;                                                  histo = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT it_hrp1001 ASCENDING BY objid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM hrp1001 INTO TABLE it_hrp1001_chk WHERE plvar = '01' AND&lt;/P&gt;&lt;P&gt;                                                      otype = 'BA' AND&lt;/P&gt;&lt;P&gt;                                                      rsign = 'A' AND&lt;/P&gt;&lt;P&gt;                                                      relat = '003' AND&lt;/P&gt;&lt;P&gt;                                                      sclas = 'BS' AND&lt;/P&gt;&lt;P&gt;                                                      sobid = '50001710' AND&lt;/P&gt;&lt;P&gt;                                                      histo = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_struct INTO wa_struct.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; WRITE : / wa_struct-pernr, wa_struct-begda.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  lv_hrobjid = wa_struct-pernr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****************************************The problem is here...... it_hrp1001 is not fetching value in wa_hrp1001 so that sy-subrc is 4. Thats correct but it should print something but nothing is getting printed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT it_hrp1001 into wa_hrp1001 WHERE objid EQ lv_hrobjid.&lt;/P&gt;&lt;P&gt;****************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      READ TABLE it_hrp1001_chk INTO wa_hrp1001_chk WITH KEY &lt;/P&gt;&lt;P&gt;                                                           objid =  wa_hrp1001-sobid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;        WRITE : / 'Some Logic'.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;        WRITE : / 'Some Logic'.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;      WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'Some Logic'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ENDIF.&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;ENDLOOP.&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;Mistry Wasim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 06:42:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872509#M673974</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T06:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Where Condition while Looping</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872510#M673975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;goo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;go through this example and try accordingly.&lt;/P&gt;&lt;P&gt;constants:       c_var(15) type c value ' IN S_RANGE'.&lt;/P&gt;&lt;P&gt;parameters:&lt;/P&gt;&lt;P&gt;   p_table type dd02l-tabname, " Parameter to capture table name.&lt;/P&gt;&lt;P&gt;   p_field(10) type c. " Parameter to capture field name.&lt;/P&gt;&lt;P&gt;data: v_where type string.&lt;/P&gt;&lt;P&gt;concatenate p_field c_var into v_where.&lt;/P&gt;&lt;P&gt;try.&lt;/P&gt;&lt;P&gt;      select * into corresponding fields of table &amp;lt;dyn_table&amp;gt;&lt;/P&gt;&lt;P&gt;                   from (p_table) where (v_where) .&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      if sy-dbcnt = 0.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;        write : text-t02.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; Exception Catching.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    catch cx_root into o_field.&lt;/P&gt;&lt;P&gt;      text = o_field-&amp;gt;get_text( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward point if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;mrutyun^&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 06:53:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872510#M673975</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T06:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Where Condition while Looping</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872511#M673976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  Yes u can build the where clause condition dynamically as like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*declare the variable as like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;constants: otype(5) type c value 'OTYPE',&lt;/P&gt;&lt;P&gt;                 rsign(5) type c value 'RSIGN',&lt;/P&gt;&lt;P&gt;                 relat(5) type c value ''RELAT',&lt;/P&gt;&lt;P&gt;                 SCLAS(5) type c value 'SCLAS',&lt;/P&gt;&lt;P&gt;                 histo(5) type c value 'HISTO'.&lt;/P&gt;&lt;P&gt;DATA: cond type string,&lt;/P&gt;&lt;P&gt;           sel type i.&lt;/P&gt;&lt;P&gt;*Build the where clause condition as like below&lt;/P&gt;&lt;P&gt;concatente otype&lt;/P&gt;&lt;P&gt;                 space &lt;/P&gt;&lt;P&gt;                '=' &lt;/P&gt;&lt;P&gt;                 space&lt;/P&gt;&lt;P&gt;                 l_data1&lt;/P&gt;&lt;P&gt;                 'AND'&lt;/P&gt;&lt;P&gt;                rsign&lt;/P&gt;&lt;P&gt;                 space &lt;/P&gt;&lt;P&gt;                '=' &lt;/P&gt;&lt;P&gt;                 space&lt;/P&gt;&lt;P&gt;                 l_data2&lt;/P&gt;&lt;P&gt;                 'AND'&lt;/P&gt;&lt;P&gt;                relat&lt;/P&gt;&lt;P&gt;                 space &lt;/P&gt;&lt;P&gt;                '=' &lt;/P&gt;&lt;P&gt;                 space&lt;/P&gt;&lt;P&gt;                 l_data2&lt;/P&gt;&lt;P&gt;           INTO COND.      &lt;/P&gt;&lt;P&gt;sel = 1.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Call the perform            &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;perform selectquery using cond sel. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form selectquery using cond type string&lt;/P&gt;&lt;P&gt;                                       sel type i.    &lt;/P&gt;&lt;P&gt;if sel eq 1.&lt;/P&gt;&lt;P&gt;SELECT * FROM hrp1001 INTO TABLE it_hrp1001 WHERE cond.&lt;/P&gt;&lt;P&gt;elseif sel eq 2.&lt;/P&gt;&lt;P&gt;SELECT * FROM hrp1001_chk INTO TABLE it_hrp1001 WHERE cond.&lt;/P&gt;&lt;P&gt;endif&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 07:09:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872511#M673976</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T07:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Where Condition while Looping</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872512#M673977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey! guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Listen i dont have any problem with SELECT queries in my code. I just have problem with the Loop Statement which i have pointed out and that too when i am passing a where condition to it thats all. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually, the thing is that for the inner loop if the condition is not satisfied that means SY-SUBRC is 4 it is completely coming out of both the loops. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mistry Wasim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 07:22:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872512#M673977</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T07:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Where Condition while Looping</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872513#M673978</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 am not sure if we should use the check on sy-subrc = 4 check inside the loop...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;imagine we need to check for a field called 'Field'.............----&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the purpose of ....loop at internal table where Field = 'X' &lt;/P&gt;&lt;P&gt;is that only records with 'X' should come in the loop..what i believe is that since there are no records it just exits to the endloop..it will not bother to go inside &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you really need to check the case where field &amp;lt;&amp;gt; 'X'&lt;/P&gt;&lt;P&gt;it is better to write&lt;/P&gt;&lt;P&gt;loop at internal table&lt;/P&gt;&lt;P&gt;if field = 'X'.&lt;/P&gt;&lt;P&gt;write : / 'Logic'.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;write : / 'Something'.&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;the best option is to put a break point and see if the code in the loop is being accessed even when the condition is not satisfied..in this way we can have a clear picture&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls check,revert and reward if helpful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Byju&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 07:32:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872513#M673978</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T07:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Where Condition while Looping</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872514#M673979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey! Edamana,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanx for your reply.....i got the hint from your reply.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i am check the sy-subrc value outside the loop condition and its working i suppose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mistry Wasim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 07:39:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-where-condition-while-looping/m-p/2872514#M673979</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T07:39:14Z</dc:date>
    </item>
  </channel>
</rss>

