<?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: LOOP AT dynamic field in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-dynamic-field/m-p/2470978#M555525</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The help says this is not possible:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE log_exp &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;WHERE can be specified with all table-types. After WHERE, you can specify any logical expression log_exp in which the first operand of any singular comparison is a component of the internal table. For this reason, all logical expressions are possible except for IS ASSIGNED, IS REQUESTED and IS SUPPLIED. &amp;lt;b&amp;gt;Dynamic specification of a component through bracketed character-type data objects is not possible&amp;lt;/b&amp;gt;. Loops at sorted tables must have compatible operands of the logical expression. All rows are read for which the logical expression is true. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not much help I know but atleast you know where you stand.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jun 2007 10:03:47 GMT</pubDate>
    <dc:creator>former_member378318</dc:creator>
    <dc:date>2007-06-22T10:03:47Z</dc:date>
    <item>
      <title>LOOP AT dynamic field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-dynamic-field/m-p/2470977#M555524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an internal table that has a structure something like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
BEGIN OF itab,
  item(10) TYPE c,
  opt1 TYPE c,
  opt2 TYPE c,
  opt3 TYPE c,
END OF itab.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It contains values like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Item   Opt1 Opt2 Opt3
Item1   X
Item2   X    X
Item3             X&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a method that will loop dynamically on the table for a selected field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab WHERE (field) EQ 'X'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Where "field" could be Opt1, Opt2 or Opt3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this possible? I have tried using a field symbol&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;ASSIGN (field) TO &amp;lt;fs_field&amp;gt;.
LOOP AT itab WHERE &amp;lt;fs_field&amp;gt; EQ 'X'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I get the error "no component exists with the name &amp;lt;fs_field&amp;gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 09:12:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-dynamic-field/m-p/2470977#M555524</guid>
      <dc:creator>former_member267246</dc:creator>
      <dc:date>2007-06-22T09:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP AT dynamic field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-dynamic-field/m-p/2470978#M555525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The help says this is not possible:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE log_exp &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;WHERE can be specified with all table-types. After WHERE, you can specify any logical expression log_exp in which the first operand of any singular comparison is a component of the internal table. For this reason, all logical expressions are possible except for IS ASSIGNED, IS REQUESTED and IS SUPPLIED. &amp;lt;b&amp;gt;Dynamic specification of a component through bracketed character-type data objects is not possible&amp;lt;/b&amp;gt;. Loops at sorted tables must have compatible operands of the logical expression. All rows are read for which the logical expression is true. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not much help I know but atleast you know where you stand.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 10:03:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-dynamic-field/m-p/2470978#M555525</guid>
      <dc:creator>former_member378318</dc:creator>
      <dc:date>2007-06-22T10:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP AT dynamic field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-dynamic-field/m-p/2470979#M555526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As an alternative perhaps you can move your dynamic check to within the loop?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab.&lt;/P&gt;&lt;P&gt;ASSIGN (field) TO &amp;lt;fs_field&amp;gt;.&lt;/P&gt;&lt;P&gt;IF &amp;lt;fs_field&amp;gt; EQ 'X'.&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 10:08:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-dynamic-field/m-p/2470979#M555526</guid>
      <dc:creator>former_member378318</dc:creator>
      <dc:date>2007-06-22T10:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP AT dynamic field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-dynamic-field/m-p/2470980#M555527</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;It can't create a dynamic WHERE condition for the LOOP statament, it's possible for the SELECT only, so u need to check your fields inside of LOOP using field-symbols:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab.

 IF ........ood ide
    FIELD = &amp;lt;...&amp;gt;.
 ENDIF.

 ASSIGN (FIELD) TO &amp;lt;FS_FIELD&amp;gt;.
 CHECK &amp;lt;FS_FIELD&amp;gt; = 'X'.

ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem can be on the performance because you need to loop all records of the internal table, if you use a WHERE clauses the performace will be better.&lt;/P&gt;&lt;P&gt;So if the ITAB can have many records you should decide if it can be a good idea to use the field-symbols.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 10:18:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-dynamic-field/m-p/2470980#M555527</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-22T10:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP AT dynamic field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-dynamic-field/m-p/2470981#M555528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes. That's what I'm going to have to go with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not the best performance, but it works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 10:20:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-dynamic-field/m-p/2470981#M555528</guid>
      <dc:creator>former_member267246</dc:creator>
      <dc:date>2007-06-22T10:20:05Z</dc:date>
    </item>
  </channel>
</rss>

