<?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 the function module in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-the-function-module/m-p/4284014#M1022044</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;loop at it_tab1 into wa_tab1.&lt;/P&gt;&lt;P&gt;&amp;gt;call function ' '&lt;/P&gt;&lt;P&gt;&amp;gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;i am calling a function module all values are coming while i debug the function module but the value is not &amp;gt;moved to my internal table.&lt;/P&gt;&lt;P&gt;&amp;gt;what is my error?.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume that you are expecting that the function is going to update the values of some fields of the internatl table for the record that you are are currently on in the loop.  It would help if you can post the full piece of code, but I'll take a shot at it anyways.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I figure that most likely you are useing the fields in wa_tab1 as your input and output fields of the function that you are calling.  The issue is that this will just be updating the work area and not the actual table, so as soon as you reach the endloop the values are gone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two possible solutions to this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at it_tab1 into wa_tab1.
    l_Tabix = sy-Tabix.    

    Call function FooBar
    Importing a value of something into wa_tab1-SomeField.
  
    modify it_tab1 from wa_tab1 index l_Tabix.  &amp;lt;-This is what you're missing

endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note in the above code, the modify statement actaully moves the values from the work area to the internal table record.  Inside the loop you don't really need to use the "index l_Tabix" part but I tend to use this to ensure that no mistakes in the logic are made.  By default it will update the current record that you are looping on.  You can also define "Transporting" for certain fields which means that it won't move all fields, just the ones that you specify.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb36a1358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb36a1358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tend to also use a lot of field-symbols because it allows you to modify records in the internal table directly.  The following is an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Field-Symbols:
  &amp;lt;tab1&amp;gt; type ????

loop at it_tab1  assigning &amp;lt;tab1&amp;gt;
 
   Call function FooBar
    Importing a value of something into &amp;lt;tab1&amp;gt;-SomeField. 
 
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~Ian&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Ian Maxwell on Aug 4, 2008 1:38 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 03 Aug 2008 23:38:36 GMT</pubDate>
    <dc:creator>ian_maxwell2</dc:creator>
    <dc:date>2008-08-03T23:38:36Z</dc:date>
    <item>
      <title>Looping the function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-the-function-module/m-p/4284011#M1022041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hai,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_tab1 into wa_tab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call function '                         '&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;i am calling a function module all values are coming while i debug the function module but the value is not moved to my internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what is my error?.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Aug 2008 05:56:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-the-function-module/m-p/4284011#M1022041</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-03T05:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Looping the function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-the-function-module/m-p/4284012#M1022042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;can you  show the piece of code what you have written.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;raam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Aug 2008 06:13:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-the-function-module/m-p/4284012#M1022042</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-03T06:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Looping the function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-the-function-module/m-p/4284013#M1022043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; i am calling a function module all values are coming while i debug the function module but the value is not moved to my internal table.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; what is my error?.&lt;/P&gt;&lt;P&gt;Values are coming into..?  values are not moved to internal table which one is that..?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it inside the function you are talking..?, show the code related to  that part.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Aug 2008 07:11:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-the-function-module/m-p/4284013#M1022043</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-03T07:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Looping the function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-the-function-module/m-p/4284014#M1022044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;loop at it_tab1 into wa_tab1.&lt;/P&gt;&lt;P&gt;&amp;gt;call function ' '&lt;/P&gt;&lt;P&gt;&amp;gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;i am calling a function module all values are coming while i debug the function module but the value is not &amp;gt;moved to my internal table.&lt;/P&gt;&lt;P&gt;&amp;gt;what is my error?.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume that you are expecting that the function is going to update the values of some fields of the internatl table for the record that you are are currently on in the loop.  It would help if you can post the full piece of code, but I'll take a shot at it anyways.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I figure that most likely you are useing the fields in wa_tab1 as your input and output fields of the function that you are calling.  The issue is that this will just be updating the work area and not the actual table, so as soon as you reach the endloop the values are gone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two possible solutions to this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at it_tab1 into wa_tab1.
    l_Tabix = sy-Tabix.    

    Call function FooBar
    Importing a value of something into wa_tab1-SomeField.
  
    modify it_tab1 from wa_tab1 index l_Tabix.  &amp;lt;-This is what you're missing

endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note in the above code, the modify statement actaully moves the values from the work area to the internal table record.  Inside the loop you don't really need to use the "index l_Tabix" part but I tend to use this to ensure that no mistakes in the logic are made.  By default it will update the current record that you are looping on.  You can also define "Transporting" for certain fields which means that it won't move all fields, just the ones that you specify.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb36a1358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb36a1358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tend to also use a lot of field-symbols because it allows you to modify records in the internal table directly.  The following is an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Field-Symbols:
  &amp;lt;tab1&amp;gt; type ????

loop at it_tab1  assigning &amp;lt;tab1&amp;gt;
 
   Call function FooBar
    Importing a value of something into &amp;lt;tab1&amp;gt;-SomeField. 
 
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~Ian&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Ian Maxwell on Aug 4, 2008 1:38 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Aug 2008 23:38:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-the-function-module/m-p/4284014#M1022044</guid>
      <dc:creator>ian_maxwell2</dc:creator>
      <dc:date>2008-08-03T23:38:36Z</dc:date>
    </item>
  </channel>
</rss>

