Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Program Layout →  Modularization Statements →  Source Code Modules →  Macros 

DEFINE

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


DEFINE macro. 
  ... &1 ... &9 ...
END-OF-DEFINITION.

Effect

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 content can be defined between the statements DEFINE and END-OF-DEFINITION. A macro is not evaluated until it is included in another program (which must have correct syntax). Currently, a macro can only be included in other ABAP programs using its name macro.

The validity of a macro is determined by 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, up to nine placeholders &1 ... &9 can be used 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.


Notes

  • Breakpoints cannot be inserted into macros and the statements of a macro cannot be performed as individual steps in ABAP Debugger.
  • In global classes, macros are defined in a dedicated include program.
  • Apart from in the source code 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 table TRMAC is break, which sets a breakpoint depending on the current user name in the system field sy-uname.

Example

See Including Macros.

Executable Example

Macros

Continue

END-OF-DEFINITION