Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Program structure →  Modularization Statements →  Source Code Modules →  Macros 


Short Reference

Other versions: 7.31 | 7.40 | 7.54


DEFINE macro. 
  ... &1 ... &9 ...


The statement DEFINE defines a macro macro. The following naming conventions macro apply and ABAP words cannot be used. Macros can be defined in all program types, particularly in type groups.

Any number of ABAP statements can come between the statements DEFINE and END-OF-DEFINITION, except for DEFINE, END-OF-DEFINITION, and program-initiating statements. These statements form a source code section that can included under the name macro. The definition of a macro is not bound to the limits of processing blocks.

The validity of a macros is determined buy its position in the compilation unit. It can be inserted at any point after END-OF-DEFINITION in the same compilation unit. If another macro is defined with the same name, it overwrites the previous macro from its new position.

Within a macro, you can use up to nine placeholders &1 ... &9 instead of ABAP words and operands. These placeholders must be replaced by fixed words when the macro is inserted.

Programming Guideline

Only use macros in exceptional cases.


  • Breakpoints cannot be inserted into macros and the statements of a macro cannot be performed as individual steps in ABAP Debugger.
  • Apart from in the code text of a program and in type groups, macros can also be stored as cross-program macros in the table TRMAC. However no new macros should be defined in the TRMAC table. An example of a macro stored in the TRMAC table is break, which sets a breakpoint depending on the current user name in the sy-unamesystem field.


See Inserting Macros and Macros.