<?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 vs Subroutine in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-vs-subroutine/m-p/1008328#M78320</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Both are for same purpose, modularisation and reuse.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to use same set of code in the same program multiple times, then use subroutines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the same code is used in multiple programs, then create a function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both can accept and return values. You can use USING, CHANGING and TABLE parameters in subroutine and IMPORT, EXPORT, TABLES and EXCEPTIONS in function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vinod&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 16 Jul 2005 18:35:50 GMT</pubDate>
    <dc:creator>Vinod_Chandran</dc:creator>
    <dc:date>2005-07-16T18:35:50Z</dc:date>
    <item>
      <title>Function module vs Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-vs-subroutine/m-p/1008326#M78318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt; One of the main difference between Function module and the subroutine is that Function module can return values but subroutine cannot.I could not understand this point.&lt;/P&gt;&lt;P&gt;can anybody tell me how i can see the difference between fm and subroutine with an example?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Jul 2005 16:47:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-vs-subroutine/m-p/1008326#M78318</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-16T16:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Function module vs Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-vs-subroutine/m-p/1008327#M78319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, they can both return values. FMs are mainly used when a routine is to be performed by many programs. Subroutines (forms) are generally only executed within one program. You can perform routines from other programs, but it's not often done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT ztest.

DATA: count TYPE i VALUE 0.

DO 5 TIMES.
  PERFORM add CHANGING count.
  WRITE: /001 'The new value is:', count.
ENDDO.

FORM add CHANGING p_count.
  ADD 1 TO p_count.
ENDFORM.            
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Jul 2005 17:32:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-vs-subroutine/m-p/1008327#M78319</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-16T17:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: Function module vs Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-vs-subroutine/m-p/1008328#M78320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Both are for same purpose, modularisation and reuse.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to use same set of code in the same program multiple times, then use subroutines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the same code is used in multiple programs, then create a function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both can accept and return values. You can use USING, CHANGING and TABLE parameters in subroutine and IMPORT, EXPORT, TABLES and EXCEPTIONS in function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vinod&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Jul 2005 18:35:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-vs-subroutine/m-p/1008328#M78320</guid>
      <dc:creator>Vinod_Chandran</dc:creator>
      <dc:date>2005-07-16T18:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Function module vs Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-vs-subroutine/m-p/1008329#M78321</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;As mentioned, both forms and FMs are &amp;lt;i&amp;gt;reusable modularization units&amp;lt;/i&amp;gt;. To distinguish we generally say that forms are used for &amp;lt;b&amp;gt;internal modularization&amp;lt;/b&amp;gt; and FMs are used for &amp;lt;b&amp;gt;external modularization&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To decide on which to implement, consider whether you need the content to be used just for a limited program or wheteher it can be called from many independent programs. For the first purpose it is better to implement a form whereas for the second we implement an FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, ABAP does not isolate the usage context. That is; you can call a form from another program within whose code the form is not actually implemented. However, this requires attention since the form may utilize global variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The same issue holds for FMs. FMs are encapsulated in &amp;lt;i&amp;gt;function groups&amp;lt;/i&amp;gt; and function groups may have global variables that can be globally used by all FMs inside it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Serdar &amp;lt;a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d"&amp;gt;[ BC ]&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Jul 2005 21:18:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-vs-subroutine/m-p/1008329#M78321</guid>
      <dc:creator>ssimsekler</dc:creator>
      <dc:date>2005-07-16T21:18:21Z</dc:date>
    </item>
  </channel>
</rss>

