<?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: Looping over fields from internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-over-fields-from-internal-table/m-p/1644674#M286928</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, you can loop thru the columns(fields) of an internal table like so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;field-symbols: &amp;lt;fs&amp;gt;.

loop at itab.

do.

* Here you can use the field name instead of SY-INDEX
   assign component sy-index of structure itab to &amp;lt;fs&amp;gt;.
   if sy-subrc &amp;lt;&amp;gt;.
   exit.
   endif.

* Now that you have access to the field via field symbol, you can compare 
* this value.
Write:/ &amp;lt;fs&amp;gt;.

enddo.  

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 26 Nov 2006 22:01:06 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2006-11-26T22:01:06Z</dc:date>
    <item>
      <title>Looping over fields from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-over-fields-from-internal-table/m-p/1644673#M286927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In a FM I have to check records of two ITABs against each other. Most fields can be checked 1:1 but some must be checked according to some business logic.&lt;/P&gt;&lt;P&gt;I first want to check field-by-field and then I want to deal with exceptions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question: How can I loop over fields in an ITAB in such a manner that I can compare fields?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 26 Nov 2006 21:10:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-over-fields-from-internal-table/m-p/1644673#M286927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-26T21:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over fields from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-over-fields-from-internal-table/m-p/1644674#M286928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, you can loop thru the columns(fields) of an internal table like so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;field-symbols: &amp;lt;fs&amp;gt;.

loop at itab.

do.

* Here you can use the field name instead of SY-INDEX
   assign component sy-index of structure itab to &amp;lt;fs&amp;gt;.
   if sy-subrc &amp;lt;&amp;gt;.
   exit.
   endif.

* Now that you have access to the field via field symbol, you can compare 
* this value.
Write:/ &amp;lt;fs&amp;gt;.

enddo.  

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 26 Nov 2006 22:01:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-over-fields-from-internal-table/m-p/1644674#M286928</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-11-26T22:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over fields from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-over-fields-from-internal-table/m-p/1644675#M286929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suggestion:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at Itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Read itab2 with key XXX = itab2-field1 using index.&lt;/P&gt;&lt;P&gt;  Comapre things.&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;Regards,&lt;/P&gt;&lt;P&gt;Mohan.&lt;/P&gt;&lt;P&gt;*&lt;STRONG&gt;Reward if helpful&lt;/STRONG&gt;*&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2006 04:09:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-over-fields-from-internal-table/m-p/1644675#M286929</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-27T04:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over fields from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-over-fields-from-internal-table/m-p/1644676#M286930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jans,&lt;/P&gt;&lt;P&gt;Consider that you have two internal tables ITAB1 &amp;amp; ITAB2. &lt;/P&gt;&lt;P&gt;If your table ITAB2 has got multiple entries for the same set of values for ITAB1 then you can use as under:&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;LOOP AT ITAB1.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB2 where &amp;lt;condition&amp;gt; EQ &amp;lt;ITAB1--&amp;gt;'Condition'&amp;gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDLOOP.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;If ITAB2 has just got one corresponding entry for the value in ITAB1, then you can use the read statement as under:&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;LOOP AT ITAB1.&lt;/P&gt;&lt;P&gt;READ TABLE ITAB2 WITH KEY &amp;lt;field for comaprison&amp;gt; EQ &amp;lt;&amp;gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC EQ 0.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;&amp;lt;You can treat your exception conditions here&amp;gt;&lt;/P&gt;&lt;P&gt;ENDIF.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chetan.&lt;/P&gt;&lt;P&gt;PS: Reward points if this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2006 04:20:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-over-fields-from-internal-table/m-p/1644676#M286930</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-27T04:20:53Z</dc:date>
    </item>
  </channel>
</rss>

