<?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: Macro vs. Subroutine in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/macro-vs-subroutine/m-p/3427583#M823247</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Macro:it is a code substitute. at run time if n micors are used in program it will replace the macro with actual code at every place while in subroutines only one copy of code is created at ru time between differnt calls to same routine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is dificult to manage Macro than the SubRoutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;complicated code can be written in SubRoutine than macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 24 Feb 2008 08:10:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-24T08:10:27Z</dc:date>
    <item>
      <title>Macro vs. Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/macro-vs-subroutine/m-p/3427582#M823246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI ALL,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could anybody please tell me the difference between macro and subroutine?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Feb 2008 07:36:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/macro-vs-subroutine/m-p/3427582#M823246</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-24T07:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: Macro vs. Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/macro-vs-subroutine/m-p/3427583#M823247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Macro:it is a code substitute. at run time if n micors are used in program it will replace the macro with actual code at every place while in subroutines only one copy of code is created at ru time between differnt calls to same routine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is dificult to manage Macro than the SubRoutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;complicated code can be written in SubRoutine than macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Feb 2008 08:10:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/macro-vs-subroutine/m-p/3427583#M823247</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-24T08:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro vs. Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/macro-vs-subroutine/m-p/3427584#M823248</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;Macros can only be used in the program the are defined in and only after the definition.&lt;/P&gt;&lt;P&gt;Macros can take max 9 parameters.&lt;/P&gt;&lt;P&gt;Macros are expanded at compilation / generation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subroutines (FORM) can be called from both the program the are defined in and other programs ('perform &lt;/P&gt;&lt;P&gt;' of 'perform in program ').&lt;/P&gt;&lt;P&gt;Subroutines can take any amount of parameters.&lt;/P&gt;&lt;P&gt;Subroutines are 'expanded' at runtime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Functions are just like FORMs, but are intended to be called external.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some differences between FUNCTIONs and FORMs:&lt;/P&gt;&lt;P&gt;The name of a FORM must be unique within the program (two programs can have different FORMs with the same name). A FORM is intended to be called internal (from within the program, however by a 'trick' you can call them external).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The name of a FUNCTION has to be unique throughout the system. A FUNCTION is intended to be called external (and is thus shared by 'many' programs).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The latter is more important for programmers and maintenance. Since a FUNCTION is called external, it is important to keep the interface (parameters) the same. The interface of a FORM (which is intended to be called internal) is check when debugging a program (but it is only checked within the program that is debugged). So if the interface of a FORM is changed, but the call to the FORM (perform ) is not, the debugger will notice this and issue an error message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general:&lt;/P&gt;&lt;P&gt;A MACRO is more or less an abbreviation for some lines of code that are used more than once or twice.&lt;/P&gt;&lt;P&gt;A FORM is a local subroutine (which can be called external).&lt;/P&gt;&lt;P&gt;A FUNCTION is (more or less) a subroutine that is called external.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since debugging a MACRO is not really possible, prevent the use of them (I've never used them, but seen them in action). If the subroutine is used only local (called internal) use a FORM. If the subroutine is called external (used by more than one program) use a FUNCTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reward Points if found helpfull..&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Cheers,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Chandra Sekhar.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Feb 2008 08:36:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/macro-vs-subroutine/m-p/3427584#M823248</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-24T08:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro vs. Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/macro-vs-subroutine/m-p/3427585#M823249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;-MACRO is reusable statement . &lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------" /&gt;&lt;P&gt;DEFINE macro &lt;/P&gt;&lt;P&gt;Call wherever needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the example code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: RESULT TYPE I,&lt;/P&gt;&lt;P&gt;N1 TYPE I VALUE 5,&lt;/P&gt;&lt;P&gt;N2 TYPE I VALUE 6.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE OPERATION.&lt;/P&gt;&lt;P&gt;RESULT = &amp;amp;1 &amp;amp;2 &amp;amp;3.&lt;/P&gt;&lt;P&gt;OUTPUT &amp;amp;1 &amp;amp;2 &amp;amp;3 RESULT.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE OUTPUT.&lt;/P&gt;&lt;P&gt;WRITE: / 'The result of &amp;amp;1 &amp;amp;2 &amp;amp;3 is', &amp;amp;4.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPERATION 4 + 3.&lt;/P&gt;&lt;P&gt;OPERATION 2 ** 7.&lt;/P&gt;&lt;P&gt;OPERATION N2 - N1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The produces the following output:&lt;/P&gt;&lt;P&gt;The result of 4 + 3 is 7&lt;/P&gt;&lt;P&gt;The result of 2 ** 7 is 128&lt;/P&gt;&lt;P&gt;The result of N2 - N1 is 1&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUBROUTINE :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It  is also reussablethe name of the subroutine. The optional additions USING and CHANGING define the parameter interface. Like any other processing block, subroutines cannot be nested. You should therefore place your subroutine definitions at the end of the program, especially for executable programs. &lt;/P&gt;&lt;P&gt;syn:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Calling :&lt;/P&gt;&lt;P&gt;PERFORM TEST&lt;/P&gt;&lt;P&gt;WRITE: / fd1,fd2,fd3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Defining:&lt;/P&gt;&lt;P&gt;FORM TEST&lt;/P&gt;&lt;P&gt;fd1 = 300&lt;/P&gt;&lt;P&gt; WRITE: /fd1 ,fd2&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub types:&lt;/P&gt;&lt;P&gt;Internal subroutines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Internal subroutines in the sense ..subroutines which are defined and used in a same program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;External subroutines:&lt;/P&gt;&lt;P&gt;External in the sense if you create a sub routine in one program and you&amp;#146;re calling this subroutine in another program ..then this is external subroutine&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Feb 2008 08:47:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/macro-vs-subroutine/m-p/3427585#M823249</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-24T08:47:54Z</dc:date>
    </item>
  </channel>
</rss>

