ABAP Macro is basically a Modularization Technique. Some important points to remember about ABAP Macros are as follows.
Structure of a Macro.
- The Macro Definition should occur before the Macro is used.
- All the statements used in the Macro should be defined between the DEFINE and END-OF-DEFINITION.
- The statements defined in the Macro can hold not more than 9 place holders (&1, &2, &3,&4,......&8,&9)
- Basically a Macro does not belong to the DEFINITION part of the program
- Any ABAP program has PROCESSING BLOCKS and the DEFINE STATEMENT in a MACROS is not interpreted before the PROCESSING BLOCKS in the program
- MACROS are NOT OPERATIONAL STATEMENTS.
- A MACRO cannot call itself
- Another MACRO can be called within a MACRO
Examples of Macro
* Parameter Declaration
Parameters: d_num1 type i,
d_num2 type i.
* Data Declaration
DATA: d_res TYPE i.
* This Macro performs the operation
d_res = &1 &2 &3.
doit &1 &2 &3 d_res.
* This Macro gives the result
write: / 'The result of &1 &2 &3 is', &4.
operation d_num1 - d_num2.
operation d_num1 + d_num2.
operation d_num1 * d_num2.
See Also: Function Modules in ABAP
SAP ABAP RFCs
SAP ABAP BAPIS