<?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: macros in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/macros/m-p/3166563#M753277</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no u cant call macros &lt;/P&gt;&lt;P&gt;ucan call fms&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Dec 2007 05:19:50 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-12-21T05:19:50Z</dc:date>
    <item>
      <title>macros</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/macros/m-p/3166562#M753276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can we call macros from one program to another?plz tell&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2007 05:18:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/macros/m-p/3166562#M753276</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-21T05:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: macros</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/macros/m-p/3166563#M753277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no u cant call macros &lt;/P&gt;&lt;P&gt;ucan call fms&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2007 05:19:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/macros/m-p/3166563#M753277</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-21T05:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: macros</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/macros/m-p/3166564#M753278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srinath,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to reuse the same set of statements more than once in a program, you can include them in a macro. For example, this can be useful for long calculations or complex WRITE statements. You can only use a macro within the program in which it is defined, and it can only be called in lines of the program following its definition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following statement block defines a macro :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Macros do not belong to the definition part of the program. This means that the DEFINE...END-OF-DEFINITION block is not interpreted before the processing blocks in the program. At the same time, however, macros are not operational statements that are executed within a processing block at runtime. When the program is generated, macro definitions are not taken into account at the point at which they are defined&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A macro definition inserts a form of shortcut at any point in a program and can be used at any subsequent point in the program. As the programmer, you must ensure that the macro definition occurs in the program before the macro itself is used. Particular care is required if you use both macros and include programs, since not all include programs are included in the syntax check (exception: TOP include).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To use a macro, use the following form: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[ ... ].&lt;/P&gt;&lt;P&gt;When the program is generated, the system replaces by the defined statements and each placeholder &amp;amp;i by the parameter &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;. You can use macros within macros. However, a macro cannot call itself. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: RESULT TYPE I,N1 TYPE I VALUE 5,N2 TYPE I VALUE 6.&lt;/P&gt;&lt;P&gt;DEFINE OPERATION. RESULT = &amp;amp;1 &amp;amp;2 &amp;amp;3.OUTPUT &amp;amp;1 &amp;amp;2 &amp;amp;3 RESULT.END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;DEFINE OUTPUT. WRITE: / 'The result of &amp;amp;1 &amp;amp;2 &amp;amp;3 is', &amp;amp;4.END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;OPERATION 4 + 3.OPERATION 2 ** 7.OPERATION N2 - N1.&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;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Kindly Award Points If You Find The Reply Helpful&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Chaitanya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2007 05:21:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/macros/m-p/3166564#M753278</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-21T05:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: macros</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/macros/m-p/3166565#M753279</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 are basically used for complex calculation and Write statements.U can reuse them more than once in a program &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 are expanded at compilation / generation. Subroutines (FORM) can be called from both the program the are defined in and other programs . A MACRO is more or less an abbreviation for some lines of code that are used more than once or twice. A FORM is a local subroutine (which can be called external). A FUNCTION is (more or less) a subroutine that is called external. Since debugging a MACRO is not really possible, prevent the use of them (I&amp;#146;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;/P&gt;&lt;P&gt;The macros, which we may use,&lt;/P&gt;&lt;P&gt;(stored in table TRMAC)&lt;/P&gt;&lt;P&gt;, we cannot debug that code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MACROS =&amp;gt;&lt;/P&gt;&lt;P&gt;Getting a feel of macros&lt;/P&gt;&lt;P&gt;The basic syntax of macros is as follows:&lt;/P&gt;&lt;P&gt;DEFINE macro_name. "Macro Definition&lt;/P&gt;&lt;P&gt;&amp;#133;&amp;#133;&amp;#133;&amp;#133;&amp;#133;. Statements&lt;/P&gt;&lt;P&gt;&amp;#133;&amp;#133;&amp;#133;&amp;#133;&amp;#133;. Statements&lt;/P&gt;&lt;P&gt;&amp;#133;&amp;#133;&amp;#133;&amp;#133;&amp;#133;&amp;#133;&amp;#133;&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION. "Macro Definition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;macro_name par1 par2 &amp;#133;par9. "Macro call -parameters separated by spaces&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within the DEFINE... and END-OF-DEFINITION lies the body of the macro&amp;#151;the statements that you wish to be executed each time the macro is called. These statements may be any valid ABAP statements, such as WRITE, CLEAR, FORM calls, or database statements such as SELECT or UPDATE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To familiarize yourself with the working of macros, it's necessary to take a close look at exactly what happens when an ABAP program containing a macro call is generated. Consider Listing A.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All ABAP programs must be generated before they can be executed. At the time of program generation, the system supplants each macro call, as shown in Listing A, with the statement(s) placed between the macro definition. Furthermore, the parameters passed at the time of macro calling are copied in place of the any placeholders (numbered &amp;amp;1, &amp;amp;2 &amp;#133;&amp;amp;9) found in the body of the macro definition. The system simply ignores the presence of the macros during the execution of the program&amp;#151;that is, all statements are executed as a single block of code:&lt;/P&gt;&lt;P&gt;write : int1.&lt;/P&gt;&lt;P&gt;write : int2.&lt;/P&gt;&lt;P&gt;write : int3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other than readability and meaningfulness, macros also offer performance advantages. For testing purposes, I wrote a macro that incremented the value of a variable by 1 and called the macro N times via a DO loop, as shown here:&lt;/P&gt;&lt;P&gt;DEFINE INCREMENT.&lt;/P&gt;&lt;P&gt;ADD 1 TO &amp;amp;1.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO N TIMES.&lt;/P&gt;&lt;P&gt;INCREMENT VAR1.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Macros are used for calculation or somthing that u want to perform again &amp;amp; again.&lt;/P&gt;&lt;P&gt;e.g if you want to build a fieldcatalog in alv.then u can use macros for this.&lt;/P&gt;&lt;P&gt;while subroutines are used for making ur program modular and structured.so that every code that you have written would be understood easily&lt;/P&gt;&lt;P&gt;&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;&lt;STRONG&gt;Reward points if found helpful.....&lt;/STRONG&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>Fri, 21 Dec 2007 05:25:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/macros/m-p/3166565#M753279</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-21T05:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: macros</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/macros/m-p/3166566#M753280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i mean to say macros we can use in differen -different programs?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2007 05:31:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/macros/m-p/3166566#M753280</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-21T05:31:09Z</dc:date>
    </item>
  </channel>
</rss>

