<?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: Problems with static variables. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647904#M288095</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. If you want to use the STATIC concept,&lt;/P&gt;&lt;P&gt;   (so that value is retained)&lt;/P&gt;&lt;P&gt;2. then use EXPORT IMPORT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. like this, inside the FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; DATA : NUM TYPE I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IMPORT NUM FROM MEMORY ID 'NUM'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF NUM = 0.&lt;/P&gt;&lt;P&gt;    NUM = 5.&lt;/P&gt;&lt;P&gt;    export num to memory id 'NUM'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. THIS WILL WORK, EVEN IF WE RUN THE PROGRAM&lt;/P&gt;&lt;P&gt;   MANY TIMES.&lt;/P&gt;&lt;P&gt;   I just tried it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;amit m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Nov 2006 12:38:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-11-13T12:38:51Z</dc:date>
    <item>
      <title>Problems with static variables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647896#M288087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to use the locking concept inside my function module using static variables. In the first run i expect static variables to be set and in the next run if this variable is set, then the same code shall not be executed by another user. Unfortunately i observe that after the first run, the value is lost and in the next run, the value of the static variable is not present. Why is this so and is there any way to implement this ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2006 12:03:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647896#M288087</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-13T12:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with static variables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647897#M288088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u cant use static variables this way...as one user runs &amp;amp; next some other use runs from some other machine...instead once first user runs..may be u can set flag in a table and when second user runs...check for the flag and stop running the code...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2006 12:06:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647897#M288088</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-13T12:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with static variables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647898#M288089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then whats the use of static variables ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also would a export/import to memory be a better option than storing a flag in a database table ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2006 12:09:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647898#M288089</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-13T12:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with static variables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647899#M288090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;export/import is used within a session...means on a system if one user executes &amp;amp; then second user executes it works...But users using various systems at various locations will not help it out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2006 12:13:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647899#M288090</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-13T12:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with static variables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647900#M288091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jaydeep,&lt;/P&gt;&lt;P&gt;  Where did you declare the staics variable? In the top include or in the source code section of the fm?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2006 12:15:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647900#M288091</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-13T12:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with static variables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647901#M288092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used it within the function module. Unfortunately when i declare it in the top include, it says statics can only be used in forms and function modules !!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2006 12:18:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647901#M288092</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-13T12:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with static variables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647902#M288093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi jaydeep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. the value is lost and in the next run, the value of the static variable is not present&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thats true.&lt;/P&gt;&lt;P&gt;If we come out of the program, and then call the FM,&lt;/P&gt;&lt;P&gt;its value will be lost.&lt;/P&gt;&lt;P&gt;(BCOS the session is different, each time we run the program)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. If we call the SAME FM TWICE, in the same program,&lt;/P&gt;&lt;P&gt;   then in the 2nd call,&lt;/P&gt;&lt;P&gt;   it will RETAIN the value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ( I tried, it works like this only)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;amit m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2006 12:33:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647902#M288093</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-13T12:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with static variables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647903#M288094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then i think the only way to do the locking concept would be to store it in a database table or do a import/export ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2006 12:36:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647903#M288094</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-13T12:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with static variables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647904#M288095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. If you want to use the STATIC concept,&lt;/P&gt;&lt;P&gt;   (so that value is retained)&lt;/P&gt;&lt;P&gt;2. then use EXPORT IMPORT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. like this, inside the FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; DATA : NUM TYPE I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IMPORT NUM FROM MEMORY ID 'NUM'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF NUM = 0.&lt;/P&gt;&lt;P&gt;    NUM = 5.&lt;/P&gt;&lt;P&gt;    export num to memory id 'NUM'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. THIS WILL WORK, EVEN IF WE RUN THE PROGRAM&lt;/P&gt;&lt;P&gt;   MANY TIMES.&lt;/P&gt;&lt;P&gt;   I just tried it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;amit m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2006 12:38:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647904#M288095</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-13T12:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with static variables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647905#M288096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jaydeep,&lt;/P&gt;&lt;P&gt;   The Import/ Export wont work because two users wont be accessing the code at the same time. Hence once one user comes out of run mode, u will lose the data. Better u use SET/GET parameters. It will work for sure. But make sure to clear the flag once the first user wants to unlock the data for the others to update.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2006 12:44:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647905#M288096</guid>
      <dc:creator>former_member283648</dc:creator>
      <dc:date>2006-11-13T12:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with static variables.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647906#M288097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. If u want to use such kind of flag/lock&lt;/P&gt;&lt;P&gt;    ACROSS USERS - ACROSS SESSIONs,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. then use EXPORT TO DATABASE concept&lt;/P&gt;&lt;P&gt;   (and not export to memory id)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. This code in FM, will make it clear and distinguishable.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    (The value in NUM_DB will be imported, in new sessions, new logins also.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA : NUM_MEMORY TYPE I.&lt;/P&gt;&lt;P&gt;  DATA : NUM_DB TYPE I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IMPORT NUM_MEMORY FROM MEMORY ID 'NUM_MEMORY'.&lt;/P&gt;&lt;P&gt;  &amp;lt;b&amp;gt;IMPORT NUM_DB FROM DATABASE INDX(XX) ID 'NUM_DB'.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF NUM_MEMORY = 0.&lt;/P&gt;&lt;P&gt;    NUM_MEMORY = 5.&lt;/P&gt;&lt;P&gt;    export num_MEMORY to memory id 'NUM_MEMORY'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF NUM_DB = 0.&lt;/P&gt;&lt;P&gt;    NUM_DB = 10.&lt;/P&gt;&lt;P&gt;   &amp;lt;b&amp;gt; export num_DB to DATABASE  INDX(XX) ID 'NUM_DB'.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;amit m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2006 12:56:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-static-variables/m-p/1647906#M288097</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-13T12:56:10Z</dc:date>
    </item>
  </channel>
</rss>

