SAP MACRO INCLUDE



Get Example source ABAP code based on a different SAP table
  



Inserting Macros

ABAP_SYNTAX
macro $[p1 p2 ... $].

What does it do?
If a macro is listed as the first word in an ABAP statement instead of a valid ABAP keyword, then its content is included in the source code at this position.
To create a syntactically correct program, the included macro may only contain complete ABAP statements except for DEFINE and END-OF-DEFINITION, and program-initiating statements. These statements create a source code section that is included in the current source code. The statements of the macro are not bound to the limits of processing blocks.
Appropriate ABAP words or operands p1, p2, ... must be passed to all placeholders of the macro. The specified operands p1 , p2, replace the placeholders literally, one after another. In addition to the content of the literals, the characters are converted to uppercase letters.
The ABAP Compiler searches for a macro specified in an ABAP program as follows: In the preceding source code of the same compilation unit. In the type pools that can be used by the program. Local macros of the program hide macros of the same name in type pools. In database table TRMAC, macros in type pools usually follow different naming conventions to those in TRMAC and therefore nothing should be hidden.
A macro can insert other macros but not itself.

ABAP_PGL
Only use macros in exceptional cases.
ABAP_PGL_END



Latest notes:

In global classes, macros are defined and searched for in a dedicated include program.
ABAP_HINT_END



Example ABAP Coding

In this example, the two macros operation and output are defined. output is nested in operation. operation is called three times with different parameters. Note how the placeholders 1, 2, ... are literally replaced in the macros.
ABEXA 01122
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
Macros
ABAP_EXAMPLE_END