<?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: Reg: Macros in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-macros/m-p/1825627#M352315</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;&amp;lt;b&amp;gt;Macros&amp;lt;/b&amp;gt; &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;The following statement block defines a macro &amp;lt;macro&amp;gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE &amp;lt;macro&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   &amp;lt;statements&amp;gt;&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;You must specify complete statements between DEFINE and END-OF-DEFINITION. These statements can contain up to nine placeholders (&amp;amp;1, &amp;amp;2, ..., &amp;amp;9). You must define the macro before the point in the program at which you want to use it. &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. For this reason, they do not appear in the overview of the structure of ABAP programs.&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;&amp;lt;macro&amp;gt; [&amp;lt;p1&amp;gt; &amp;lt;p2&amp;gt; ... &amp;lt;p9&amp;gt;].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the program is generated, the system replaces &amp;lt;macro&amp;gt; by the defined statements and each placeholder &amp;amp;i by the parameter &amp;lt;p i &amp;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;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;&lt;/P&gt;&lt;P&gt;The result of 4 + 3 is 7&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result of 2 ** 7 is 128&lt;/P&gt;&lt;P&gt;&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;Here, two macros, OPERATION and OUTPUT, are defined. OUTPUT is nested in OPERATION. OPERATION is called three times with different parameters. Note how the placeholders &amp;amp;1, &amp;amp;2, ... are replaced in the macros.&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 example shows that a macro definition only works in the program lines following its definition. Do not copy it! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose we have a program with a subroutine TEST:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROGRAM MACRO_TEST.&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 TEST.&lt;/P&gt;&lt;P&gt;  WRITE '...'.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose we then changed the program to the following: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROGRAM MACRO_TEST.&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 TEST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE MACRO.&lt;/P&gt;&lt;P&gt;    WRITE '...'.&lt;/P&gt;&lt;P&gt;  ENDFORM.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MACRO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inserting the macro changes nothing in the generated form of the program. Processing blocks - here a subroutine - are always indivisible. We could also write the program as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROGRAM MACRO_TEST.&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 MACRO.&lt;/P&gt;&lt;P&gt;    WRITE '...'.&lt;/P&gt;&lt;P&gt;  ENDFORM.&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;FORM TEST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MACRO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The most essential feature of a macro definition is that it should occur before the macro is used. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Please reward points if useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Feb 2007 12:06:21 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-02T12:06:21Z</dc:date>
    <item>
      <title>Reg: Macros</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-macros/m-p/1825624#M352312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can any body tell me what r macros and where we use them and from&lt;/P&gt;&lt;P&gt;where i can learn macros.......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Feb 2007 11:44:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-macros/m-p/1825624#M352312</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-02T11:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Reg: Macros</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-macros/m-p/1825625#M352313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Macros &lt;/P&gt;&lt;P&gt;Definition&lt;/P&gt;&lt;P&gt;A series of commands and procedures that are carried out in response to a single command or keystroke, or identified by a single name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use&lt;/P&gt;&lt;P&gt;You use macros to configure UI patterns in CAF Core to calculate field values based on physical field properties in the Logical Data Source tab pages of the Flex Tree and History Log components. In these applications, you use macros to define field variants.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Structure&lt;/P&gt;&lt;P&gt;CAF Core uses the following predefined set of macro functions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;#9679;     @switch&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This macro evaluates the contents of the mapped physical field and compares it with the logical field name until it makes a match. The result is the value contained in the logical field. The macro @switch returns value, default_value if there is no corresponding logical field. The macro returns the value nullif a default value is not specified.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@switch(@level(), &amp;#147;Category&amp;#147;, false, true)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;#9679;     @format&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This macro evaluates the aspect field and calls the java.Text.MessageFormat format. The macro @format combines the macro function with the logical field and array of arguments as parameters. The result is new formatting of a field aspect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@format(&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#147;CreatedAt:\n &lt;SPAN __jive_macro_name="0"&gt;&lt;/SPAN&gt;\nCreated By:\n &lt;SPAN __jive_macro_name="1"&gt;&lt;/SPAN&gt;\nDescription:\n &lt;SPAN __jive_macro_name="2"&gt;&lt;/SPAN&gt;&amp;#147;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[createdAt],&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[createdBy],&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[description]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;#9679;     @level&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This macro returns the name of the level you are currently evaluating in the application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;#9679;     @component_mime&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This macro returns the absolute web resource URL of the component&amp;#146;s mime. It takes the development component (DC) name, component name, and relative path as parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@component_mime(&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#147;sap.com/caf&lt;SUB&gt;UI&lt;/SUB&gt;ptn~historylog&amp;#148;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#147;com.sap.caf.ui.pt.historylog.components.log.HistoryLog&amp;#148;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#147;buttons/buttons-preview.gif&amp;#148;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;#9679;     @app_mime&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The macro returns the absolute web resource URL of the application&amp;#146;s mime. It takes the DC name, application name, and relative path as parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;#9679;     @dc_mime&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The macro returns the absolute web resource URL of the development component&amp;#146;s mime. It takes the DC name and relative path as parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;#9679;     @sap_mime&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This macro returns the absolute web resource URL to the standard image.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@sap_mime(&amp;#147;s_b_disp.gif&amp;#147;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;#9679;     @substring&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This macro returns substring expressions similar to the java.text.String substring function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@substring([FullName], 0, 50)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;refer....&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04s/helpdata/en/64/fe4efc8d9c4b1a83eec2bbb14ea213/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04s/helpdata/en/64/fe4efc8d9c4b1a83eec2bbb14ea213/content.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Feb 2007 11:49:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-macros/m-p/1825625#M352313</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-02T11:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Reg: Macros</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-macros/m-p/1825626#M352314</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;Apart from their readability and efficiency, macros can be more effective than other modularisation techniques because of their versatility in replacing different ABAP statements in solving business problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABAP provides only the syntax for creating macros. It's up to the programmer to devise ways that best suit the requirements. The power of macro programming lies in mastering the ways macros can be used in ABAP programs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please look at the following documentation and examples on macros&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.builderau.com.au/news/soa/Unleash_the_power_of_macros_in_ABAP/0,339028227,320276178,00.htm" target="test_blank"&gt;http://www.builderau.com.au/news/soa/Unleash_the_power_of_macros_in_ABAP/0,339028227,320276178,00.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db972835c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db972835c111d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/ab022.htm" target="test_blank"&gt;http://www.sap-img.com/ab022.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Feb 2007 11:52:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-macros/m-p/1825626#M352314</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-02T11:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Reg: Macros</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-macros/m-p/1825627#M352315</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;&amp;lt;b&amp;gt;Macros&amp;lt;/b&amp;gt; &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;The following statement block defines a macro &amp;lt;macro&amp;gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE &amp;lt;macro&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   &amp;lt;statements&amp;gt;&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;You must specify complete statements between DEFINE and END-OF-DEFINITION. These statements can contain up to nine placeholders (&amp;amp;1, &amp;amp;2, ..., &amp;amp;9). You must define the macro before the point in the program at which you want to use it. &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. For this reason, they do not appear in the overview of the structure of ABAP programs.&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;&amp;lt;macro&amp;gt; [&amp;lt;p1&amp;gt; &amp;lt;p2&amp;gt; ... &amp;lt;p9&amp;gt;].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the program is generated, the system replaces &amp;lt;macro&amp;gt; by the defined statements and each placeholder &amp;amp;i by the parameter &amp;lt;p i &amp;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;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;&lt;/P&gt;&lt;P&gt;The result of 4 + 3 is 7&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result of 2 ** 7 is 128&lt;/P&gt;&lt;P&gt;&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;Here, two macros, OPERATION and OUTPUT, are defined. OUTPUT is nested in OPERATION. OPERATION is called three times with different parameters. Note how the placeholders &amp;amp;1, &amp;amp;2, ... are replaced in the macros.&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 example shows that a macro definition only works in the program lines following its definition. Do not copy it! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose we have a program with a subroutine TEST:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROGRAM MACRO_TEST.&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 TEST.&lt;/P&gt;&lt;P&gt;  WRITE '...'.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose we then changed the program to the following: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROGRAM MACRO_TEST.&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 TEST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE MACRO.&lt;/P&gt;&lt;P&gt;    WRITE '...'.&lt;/P&gt;&lt;P&gt;  ENDFORM.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MACRO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inserting the macro changes nothing in the generated form of the program. Processing blocks - here a subroutine - are always indivisible. We could also write the program as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROGRAM MACRO_TEST.&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 MACRO.&lt;/P&gt;&lt;P&gt;    WRITE '...'.&lt;/P&gt;&lt;P&gt;  ENDFORM.&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;FORM TEST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MACRO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The most essential feature of a macro definition is that it should occur before the macro is used. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Please reward points if useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Feb 2007 12:06:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-macros/m-p/1825627#M352315</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-02T12:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reg: Macros</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-macros/m-p/1825628#M352316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;also refer below demo code for understanding Use of MAcros - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE fetch_data.&lt;/P&gt;&lt;P&gt;select * from mara into table &amp;amp;1 up to 20 rows.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables mara.&lt;/P&gt;&lt;P&gt;data: begin of itab occurs 0.&lt;/P&gt;&lt;P&gt;        include structure mara.&lt;/P&gt;&lt;P&gt;data end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fetch_data ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write:/ itab-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Feb 2007 12:12:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-macros/m-p/1825628#M352316</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-02T12:12:38Z</dc:date>
    </item>
  </channel>
</rss>

