- If you want to reuse the same set of statements more than once in a program, you can include them in a macro.
- Syntax to define Macro's:
DEFINE <macro>.
<statements>
END-OF-DEFINITION.
- Syntax call Macro's.
<macro> [<p1> <p2> ... <p9>].
Ex:
Steps :
Source Code
REPORT ZTEST_MACRO.
DATA : RES TYPE P DECIMALS 2.
PARAMETERS : A1 TYPE I,
B1 TYPE I.
DEFINE OPERATE.
RES = &1 &2 &3.
DISPLAY &1 &2 &3 RES.
BREAK-POINT.
END-OF-DEFINITION.
DEFINE DISPLAY.
WRITE : / 'RESULT &1 &2 &3 =', &4.
END-OF-DEFINITION.
OPERATE A1 + B1.
OPERATE A1 - B1.
OPERATE A1 * B1.
OPERATE A1 / B1.
- Save -> Check -> Activate -> Execute.
No comments:
Post a Comment