<?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 Subroutine in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346981#M517828</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;   what is accessing the global work area values with regard to subroutine.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Pls Thanks for your replies in advance&lt;/P&gt;&lt;P&gt;Rahul.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Jun 2007 12:53:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-15T12:53:44Z</dc:date>
    <item>
      <title>Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346981#M517828</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;   what is accessing the global work area values with regard to subroutine.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Pls Thanks for your replies in advance&lt;/P&gt;&lt;P&gt;Rahul.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 12:53:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346981#M517828</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T12:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346982#M517829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;There are some variables which are declared in the main program itself.These varaibles are accessible from any point of the program.These variables are called GLOBAL variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If in any program you have a subroutine and in that subroutine you need to use any global variable then you can go ahead and directly do so.You do not need to pass these variables using the "USING" or "CHANGING" keywords.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is how you can access the global variables in a subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sandeep.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 13:06:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346982#M517829</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T13:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346983#M517830</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;  Can u give some coding part of that &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                    and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Same thing can be done using Fun Moduled possible???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Thanks Sandeep&lt;/P&gt;&lt;P&gt;    Rahul.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 13:09:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346983#M517830</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T13:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346984#M517831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For function module, you can use global variables too, but it is recommended to pass the variables in the parameter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You just have to define the variables in the "top" include of your function group&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 13:17:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346984#M517831</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T13:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346985#M517832</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;Subroutines are procedures that you can define in any ABAP program and also call from any&lt;/P&gt;&lt;P&gt;program. Subroutines are normally called internally, that is, they contain sections of code or&lt;/P&gt;&lt;P&gt;algorithms that are used frequently locally. If you want a function to be reusable throughout the&lt;/P&gt;&lt;P&gt;system, use a function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A subroutine is a block of code introduced by FORM and concluded by ENDFORM.&lt;/P&gt;&lt;P&gt;FORM &amp;lt;subr&amp;gt; [USING ... [VALUE(]&amp;lt;pi&amp;gt;[)] [TYPE &amp;lt;t&amp;gt;|LIKE &amp;lt;f&amp;gt;]... ]&lt;/P&gt;&lt;P&gt;[CHANGING... [VALUE(]&amp;lt;pi&amp;gt;[)] [TYPE &amp;lt;t&amp;gt;|LIKE &amp;lt;f&amp;gt;]... ].&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&amp;lt;subr&amp;gt; is the name of the subroutine. The optional additions USING and CHANGING define the&lt;/P&gt;&lt;P&gt;parameter interface. Like any other processing block, subroutines cannot be nested. You&lt;/P&gt;&lt;P&gt;should therefore place your subroutine definitions at the end of the program, especially for&lt;/P&gt;&lt;P&gt;executable programs (type 1). In this way, you eliminate the risk of accidentally ending an event&lt;/P&gt;&lt;P&gt;block in the wrong place by inserting a FORM...ENDFORM block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Global Data from the Main Program&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;Subroutines can access all of the global data in the program in which they are defined (main&lt;/P&gt;&lt;P&gt;program). You therefore do not need to define a parameter interface if you do not want to change&lt;/P&gt;&lt;P&gt;any data in the subroutine, or if very little data is involved.&lt;/P&gt;&lt;P&gt;FORM HEADER.&lt;/P&gt;&lt;P&gt;WRITE: / 'Program started by', SY-UNAME,&lt;/P&gt;&lt;P&gt;/ 'on host', SY-HOST,&lt;/P&gt;&lt;P&gt;'date:', SY-DATUM, 'time:', SY-UZEIT.&lt;/P&gt;&lt;P&gt;ULINE.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;This example creates a subroutine called HEADER, which, like the example of an&lt;/P&gt;&lt;P&gt;include program, displays a list header.&lt;/P&gt;&lt;P&gt;However, if you want subroutines to perform complex operations on data without affecting the&lt;/P&gt;&lt;P&gt;global data in the program, you should define a parameter interface through which you can pass&lt;/P&gt;&lt;P&gt;exactly the data you need. In the interests of good programming style and encapsulation, you&lt;/P&gt;&lt;P&gt;should always use a parameter interface, at least when the subroutine changes data.&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Protecting Global Data Objects Against Changes&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;To prevent the value of a global data object from being changed inside a subroutine, use the&lt;/P&gt;&lt;P&gt;following statement:&lt;/P&gt;&lt;P&gt;LOCAL &amp;lt;f&amp;gt;.&lt;/P&gt;&lt;P&gt;This statement may only occur between the FORM and ENDFORM statements. With LOCAL,&lt;/P&gt;&lt;P&gt;you can preserve the values of global data objects which cannot be hidden by a data declaration&lt;/P&gt;&lt;P&gt;inside the subroutine.&lt;/P&gt;&lt;P&gt;For example, you cannot declare a table work area that is defined by the TABLES statement with&lt;/P&gt;&lt;P&gt;another TABLES statement inside a subroutine. If you want to use the table work area locally, but&lt;/P&gt;&lt;P&gt;preserve its contents outside the subroutine, you must use the LOCAL statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex.&lt;/P&gt;&lt;P&gt;PROGRAM FORM_TEST.&lt;/P&gt;&lt;P&gt;TABLES SFLIGHT.&lt;/P&gt;&lt;P&gt;PERFORM TABTEST1.&lt;/P&gt;&lt;P&gt;WRITE: / SFLIGHT-PLANETYPE, SFLIGHT-PRICE.&lt;/P&gt;&lt;P&gt;PERFORM TABTEST2.&lt;/P&gt;&lt;P&gt;WRITE: / SFLIGHT-PLANETYPE, SFLIGHT-PRICE.&lt;/P&gt;&lt;P&gt;FORM TABTEST1.&lt;/P&gt;&lt;P&gt;SFLIGHT-PLANETYPE = 'A310'.&lt;/P&gt;&lt;P&gt;SFLIGHT-PRICE = '150.00'.&lt;/P&gt;&lt;P&gt;WRITE: / SFLIGHT-PLANETYPE, SFLIGHT-PRICE.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;FORM TABTEST2.&lt;/P&gt;&lt;P&gt;LOCAL SFLIGHT.&lt;/P&gt;&lt;P&gt;SFLIGHT-PLANETYPE = 'B747'.&lt;/P&gt;&lt;P&gt;SFLIGHT-PRICE = '500.00'.&lt;/P&gt;&lt;P&gt;WRITE: / SFLIGHT-PLANETYPE, SFLIGHT-PRICE.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;When you run the program, the following is displayed:&lt;/P&gt;&lt;P&gt;A310 150.00&lt;/P&gt;&lt;P&gt;A310 150.00&lt;/P&gt;&lt;P&gt;B747 500.00&lt;/P&gt;&lt;P&gt;A310 150.00&lt;/P&gt;&lt;P&gt;The program creates a table work area SFLIGHT for the database table SFLIGHT.&lt;/P&gt;&lt;P&gt;Different values are assigned to the table work area SFLIGHT in TABTEST1 and&lt;/P&gt;&lt;P&gt;TABTEST2. While the values assigned in TABTEST1 are valid globally, the values&lt;/P&gt;&lt;P&gt;assigned in TABTEST2 are only valid locally.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhaskar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 13:17:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346985#M517832</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T13:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346986#M517833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;data:   gv_var1 type i,&lt;/P&gt;&lt;P&gt;	gv_var2 type i,&lt;/P&gt;&lt;P&gt;	gv_var3 type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;perform gf1.&lt;/P&gt;&lt;P&gt;perform gf2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form gf1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gv_var1 = 10.&lt;/P&gt;&lt;P&gt;gv_var3 = 20.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gv_var2 = gv_var1 + gv_var3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form gf2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write: gv_var3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 13:17:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346986#M517833</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T13:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346987#M517834</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;       A global variable defined outside of a subroutine by using the TABLES or        DATA stmts.&lt;/P&gt;&lt;P&gt;      It can be accessed from any point in the prgm,be it inside an event or inside subroutine.&lt;/P&gt;&lt;P&gt;     Variables by using TABLES stmt are always global.&lt;/P&gt;&lt;P&gt;     So,no need to use tables stmt inside a subroutine since the def is always global.&lt;/P&gt;&lt;P&gt;    Global definitions should be placed at the top of the prgm.&lt;/P&gt;&lt;P&gt;     To define a local table work area insid a subroutine,have to use LOCAL instead of tables stmt.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 13:19:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/2346987#M517834</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T13:19:09Z</dc:date>
    </item>
  </channel>
</rss>

