<?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: Function module called within a loop seems to carry over global data in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-called-within-a-loop-seems-to-carry-over-global-data/m-p/8117882#M1618158</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you debug the FM, you'll see that after each time the FM is executed, the internal tables contain the data from the previous run(s). I was surprised when I furst noticed this, but it is standard FM behavior. You may be able to find a FM (but it has to be in the same group) that clears global memory. If there is one, you can run it before each run of your main FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Sep 2011 20:21:57 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-09-15T20:21:57Z</dc:date>
    <item>
      <title>Function module called within a loop seems to carry over global data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-called-within-a-loop-seems-to-carry-over-global-data/m-p/8117881#M1618157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am calling FM "RS_COVERPAGE_SELECTIONS" inside of a loop of all variants for a program and then writing the variant values to spool.  If only one variant is entered on the selection screen, all the values are correct.  If nothing is entered, some of the variant values are carried over from a previous variant.  I am emptying the internal table returned by the FM every time before the FM executes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would some one be willing to run the following code for a program with many screen fields and many variants and tell me if they get the same behavior?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT zzzz.&lt;/P&gt;&lt;P&gt;tables: varid, varit.&lt;/P&gt;&lt;P&gt;parameters:     p_pgm type progname obligatory default 'ZFAPI004'.&lt;/P&gt;&lt;P&gt;select-options: s_var for varid-variant.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;parameters: p_varval as checkbox default 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of reptab occurs 0,&lt;/P&gt;&lt;P&gt;        report like varid-report,&lt;/P&gt;&lt;P&gt;        variant like varid-variant,&lt;/P&gt;&lt;P&gt;        ename like varid-ename,&lt;/P&gt;&lt;P&gt;        edat like varid-edat,&lt;/P&gt;&lt;P&gt;        etime like varid-etime,&lt;/P&gt;&lt;P&gt;        aename like varid-aename,&lt;/P&gt;&lt;P&gt;        aedat like varid-aedat,&lt;/P&gt;&lt;P&gt;        aetime like varid-aetime,&lt;/P&gt;&lt;P&gt;        vtext like varit-vtext,&lt;/P&gt;&lt;P&gt;      end of reptab.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;data: begin of tab_sel_options occurs 0,&lt;/P&gt;&lt;P&gt;                        flag(1) type c,&lt;/P&gt;&lt;P&gt;                        olength type x,&lt;/P&gt;&lt;P&gt;                        line  like rsvar-infoline,&lt;/P&gt;&lt;P&gt;                      end of tab_sel_options.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*&amp;gt;&amp;gt; At Selection-Screen data items &amp;lt;&amp;lt;&lt;/P&gt;&lt;P&gt;data: w_pgm like sy-repid.&lt;/P&gt;&lt;P&gt;data: itab like rseui_f4 occurs 0 with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: dyname like d020s-prog value sy-repid,&lt;/P&gt;&lt;P&gt;        dynumb like d020s-dnum value '1000'.&lt;/P&gt;&lt;P&gt;data: begin of dynpfields occurs 3.&lt;/P&gt;&lt;P&gt;        include structure dynpread.&lt;/P&gt;&lt;P&gt;data: end of dynpfields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: w_tabix    like sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of i_var occurs 0,&lt;/P&gt;&lt;P&gt;          variant like varit-variant,&lt;/P&gt;&lt;P&gt;          vtext   like varit-vtext.&lt;/P&gt;&lt;P&gt;data: end of i_var.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;  format intensified on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  write: / p_pgm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  select * from varid&lt;/P&gt;&lt;P&gt;    where report = p_pgm&lt;/P&gt;&lt;P&gt;      and variant in s_var.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    select single * from varit&lt;/P&gt;&lt;P&gt;      where langu = 'E' and report = p_pgm&lt;/P&gt;&lt;P&gt;        and variant = varid-variant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    move-corresponding varid to reptab.&lt;/P&gt;&lt;P&gt;    move-corresponding varit to reptab.&lt;/P&gt;&lt;P&gt;    append reptab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  sort reptab by variant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  skip 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  format color col_heading.&lt;/P&gt;&lt;P&gt;  write: /03 'Variant',&lt;/P&gt;&lt;P&gt;          18 'Create',&lt;/P&gt;&lt;P&gt;          47 'Modify',&lt;/P&gt;&lt;P&gt;          76 'Description'.&lt;/P&gt;&lt;P&gt;  format color off.&lt;/P&gt;&lt;P&gt;  skip 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at reptab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    format color col_total.&lt;/P&gt;&lt;P&gt;    write: /3 reptab-variant,&lt;/P&gt;&lt;P&gt;             reptab-ename(8),&lt;/P&gt;&lt;P&gt;             reptab-edat,&lt;/P&gt;&lt;P&gt;             reptab-etime,&lt;/P&gt;&lt;P&gt;             reptab-aename(8),&lt;/P&gt;&lt;P&gt;             reptab-aedat,&lt;/P&gt;&lt;P&gt;             reptab-aetime,&lt;/P&gt;&lt;P&gt;             reptab-vtext.&lt;/P&gt;&lt;P&gt;    format color off.&lt;/P&gt;&lt;P&gt;    skip 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;    if p_varval = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      clear   tab_sel_options.     " header&lt;/P&gt;&lt;P&gt;      refresh tab_sel_options.     " lines&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      call function 'RS_COVERPAGE_SELECTIONS'&lt;/P&gt;&lt;P&gt;        exporting&lt;/P&gt;&lt;P&gt;          report            = reptab-report&lt;/P&gt;&lt;P&gt;          variant           = reptab-variant&lt;/P&gt;&lt;P&gt;          no_import         = ' '&lt;/P&gt;&lt;P&gt;        tables&lt;/P&gt;&lt;P&gt;          infotab           = tab_sel_options&lt;/P&gt;&lt;P&gt;        exceptions&lt;/P&gt;&lt;P&gt;          error_message     = 1&lt;/P&gt;&lt;P&gt;          variant_not_found = 2&lt;/P&gt;&lt;P&gt;          others            = 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      loop at tab_sel_options.&lt;/P&gt;&lt;P&gt;        if sy-tabix &amp;lt; 7.&lt;/P&gt;&lt;P&gt;          continue.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        write: / tab_sel_options-line.&lt;/P&gt;&lt;P&gt;      endloop.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;      skip 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    endif.  "  p_varval = 'X'.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2011 20:11:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-called-within-a-loop-seems-to-carry-over-global-data/m-p/8117881#M1618157</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-15T20:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Function module called within a loop seems to carry over global data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-called-within-a-loop-seems-to-carry-over-global-data/m-p/8117882#M1618158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you debug the FM, you'll see that after each time the FM is executed, the internal tables contain the data from the previous run(s). I was surprised when I furst noticed this, but it is standard FM behavior. You may be able to find a FM (but it has to be in the same group) that clears global memory. If there is one, you can run it before each run of your main FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2011 20:21:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-called-within-a-loop-seems-to-carry-over-global-data/m-p/8117882#M1618158</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-15T20:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Function module called within a loop seems to carry over global data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-called-within-a-loop-seems-to-carry-over-global-data/m-p/8117883#M1618159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may wanna  look at this post&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __jive_macro_name="thread" id="1007495"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2011 20:22:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-called-within-a-loop-seems-to-carry-over-global-data/m-p/8117883#M1618159</guid>
      <dc:creator>sjeevan</dc:creator>
      <dc:date>2011-09-15T20:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Function module called within a loop seems to carry over global data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-called-within-a-loop-seems-to-carry-over-global-data/m-p/8117884#M1618160</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;Try using the function module PRINT_SELECTIONS, within this FM, the FM RS_COVERPAGE_SELECTIONS is being called. So it will not copy the previous values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pass Mode as 'A' , report name and variant name, then it will display the same output.&lt;/P&gt;&lt;P&gt;Please try it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2011 20:48:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-called-within-a-loop-seems-to-carry-over-global-data/m-p/8117884#M1618160</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-15T20:48:12Z</dc:date>
    </item>
  </channel>
</rss>

