DEFINE (ABAP Keyword)

DEFINE (ABAP Keyword) introduction and details and syntax

DEFINE

Basic
form
DEFINE macro.

Effect
Defines a program component (macro) under
the name macro . It must consist only of ABAP/4 statements and is expanded at
compilation time.

A macro should always be concluded with the
END-OF-DEFINITION statement.

In the definition, you can use &n to
reference positional parameters (n = 0 .. 9). When the macro is called, &n
is replaced by the n-th actual parameter.

Example
Define a macro
called “++” for use in the program.

DEFINE ++.
ADD 1 TO
&1.
END-OF-DEFINITION.

DATA: NUMBER TYPE I VALUE 1.

++
NUMBER.

Notes
In general, it is better to use subroutines
(FORM , FUNCTION ) rather than macros because subroutines – unlike macros – are
supported by all the ABAP/4 Development Workbench tools (including debugging,
runtime analysis, runtime error handling, …).
You cannot nest macro
definitions.