<?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: Dynamic WHERE condition in Internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-in-internal-table/m-p/1708233#M310030</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data : lv_key(10) type c value 'ANLKL',&lt;/P&gt;&lt;P&gt;       lv_ANLKL(10) type c.&lt;/P&gt;&lt;P&gt; FIELD-SYMBOLS: &amp;lt;lv_key&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            ASSIGN (lv_key) TO &amp;lt;lv_key&amp;gt;.&lt;/P&gt;&lt;P&gt;            lv_ANLKL = &amp;lt;lv_key&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       Loop at itab where  lv_ANLKL is initial.&lt;/P&gt;&lt;P&gt;       endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 29 Oct 2006 09:59:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-10-29T09:59:19Z</dc:date>
    <item>
      <title>Dynamic WHERE condition in Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-in-internal-table/m-p/1708232#M310029</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;How can we write dynamic where condition for an internal table as we can write READ statement as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : lv_key(10) type c value 'ANLKL'.&lt;/P&gt;&lt;P&gt;read table itab1 with key (lv_key) = 'ANLKL'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to write LOOP statement something like this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at itab where (lv_key) is initial.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help or pointer is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Deepak Bhalla&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Oct 2006 08:35:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-in-internal-table/m-p/1708232#M310029</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-29T08:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic WHERE condition in Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-in-internal-table/m-p/1708233#M310030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data : lv_key(10) type c value 'ANLKL',&lt;/P&gt;&lt;P&gt;       lv_ANLKL(10) type c.&lt;/P&gt;&lt;P&gt; FIELD-SYMBOLS: &amp;lt;lv_key&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            ASSIGN (lv_key) TO &amp;lt;lv_key&amp;gt;.&lt;/P&gt;&lt;P&gt;            lv_ANLKL = &amp;lt;lv_key&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       Loop at itab where  lv_ANLKL is initial.&lt;/P&gt;&lt;P&gt;       endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Oct 2006 09:59:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-in-internal-table/m-p/1708233#M310030</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-29T09:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic WHERE condition in Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-in-internal-table/m-p/1708234#M310031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;shakeela,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this will give you a syntax error, because the WHERE condition for LOOP clause is incorrect:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The condition logexp can be almost any logical expression. The only restriction is that the first field for each comparison must be a sub-field of the line structure of the internal table itab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is true, that you can't specify it dynamically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you can do as an alternative, is to check all fields that could be used dynamically against ranges and to fill just the rabges you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;pre&amp;gt;&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;  lr_bukrs type range of bseg-bukrs,&lt;/P&gt;&lt;P&gt;  lr_gjahr type range of bseg-gjahr,&lt;/P&gt;&lt;P&gt;  lr_belnr type range of bseg-belnr.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;filll range(s) dynamically ***&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;...&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;...&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;loop at itab where bukrs in lr_bukrs&lt;/P&gt;&lt;P&gt;               and gjahr in lr_gjahr&lt;/P&gt;&lt;P&gt;               and belnr in lr_belnr.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;do something&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&amp;lt;/pre&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because a where-condition on an empty range is always true, empty ranges will be ignored and only the ranges with values will be used for comparison.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To fill a range, you may use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;pre&amp;gt;&lt;/P&gt;&lt;P&gt;    PERFORM append_range &lt;/P&gt;&lt;P&gt;      USING 'IEQ' '2006' '' &lt;/P&gt;&lt;P&gt;      CHANGING lr_gjahr.&lt;/P&gt;&lt;P&gt;&amp;lt;/pre&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;using this universal reusable lightning-fast form&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;pre&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  append_range&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      append selection range&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM append_range  USING    p_signopt     TYPE c&lt;/P&gt;&lt;P&gt;                            p_low         TYPE any&lt;/P&gt;&lt;P&gt;                            p_high        TYPE any&lt;/P&gt;&lt;P&gt;                   CHANGING pt_range      TYPE table.&lt;/P&gt;&lt;P&gt;  FIELD-SYMBOLS:&lt;/P&gt;&lt;P&gt;    &amp;lt;range&amp;gt;                               TYPE ANY,&lt;/P&gt;&lt;P&gt;    &amp;lt;sign&amp;gt;                                TYPE ANY,&lt;/P&gt;&lt;P&gt;    &amp;lt;option&amp;gt;                              TYPE ANY,&lt;/P&gt;&lt;P&gt;    &amp;lt;low&amp;gt;                                 TYPE ANY,&lt;/P&gt;&lt;P&gt;    &amp;lt;high&amp;gt;                                TYPE ANY.&lt;/P&gt;&lt;P&gt;  DATA:&lt;/P&gt;&lt;P&gt;    l_ref                                 TYPE REF TO data.&lt;/P&gt;&lt;P&gt;  CREATE DATA l_ref                       LIKE LINE OF pt_range.&lt;/P&gt;&lt;P&gt;  ASSIGN l_ref-&amp;gt;* TO &amp;lt;range&amp;gt;.&lt;/P&gt;&lt;P&gt;  CHECK sy-subrc                          = 0.&lt;/P&gt;&lt;P&gt;  ASSIGN COMPONENT 'SIGN' OF STRUCTURE &amp;lt;range&amp;gt; TO &amp;lt;sign&amp;gt;.&lt;/P&gt;&lt;P&gt;  CHECK sy-subrc                          = 0.&lt;/P&gt;&lt;P&gt;  ASSIGN COMPONENT 'OPTION' OF STRUCTURE &amp;lt;range&amp;gt; TO &amp;lt;option&amp;gt;.&lt;/P&gt;&lt;P&gt;  CHECK sy-subrc                          = 0.&lt;/P&gt;&lt;P&gt;  ASSIGN COMPONENT 'LOW' OF STRUCTURE &amp;lt;range&amp;gt; TO &amp;lt;low&amp;gt;.&lt;/P&gt;&lt;P&gt;  CHECK sy-subrc                          = 0.&lt;/P&gt;&lt;P&gt;  ASSIGN COMPONENT 'HIGH' OF STRUCTURE &amp;lt;range&amp;gt; TO &amp;lt;high&amp;gt;.&lt;/P&gt;&lt;P&gt;  CHECK sy-subrc                          = 0.&lt;/P&gt;&lt;P&gt;  &amp;lt;sign&amp;gt;                                  = p_signopt(1).&lt;/P&gt;&lt;P&gt;  &amp;lt;option&amp;gt;                                = p_signopt+1(2).&lt;/P&gt;&lt;P&gt;  &amp;lt;low&amp;gt;                                   = p_low.&lt;/P&gt;&lt;P&gt;  &amp;lt;high&amp;gt;                                  = p_high.&lt;/P&gt;&lt;P&gt;  READ TABLE pt_range WITH KEY table_line = &amp;lt;range&amp;gt;&lt;/P&gt;&lt;P&gt;    TRANSPORTING NO FIELDS BINARY SEARCH.&lt;/P&gt;&lt;P&gt;  CHECK sy-subrc                          &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;  INSERT &amp;lt;range&amp;gt; INTO pt_range INDEX sy-tabix..&lt;/P&gt;&lt;P&gt;ENDFORM.                    " append_range&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/pre&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Oct 2006 12:10:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-condition-in-internal-table/m-p/1708234#M310031</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2006-10-29T12:10:11Z</dc:date>
    </item>
  </channel>
</rss>

