Wednesday 15 June 2016

Macros



  • 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.
                    <macro> [<p1> <p2> ... <p9>].

Ex:

Steps :

  • Go to Transaction Code : SE38.

  • Enter the program name , starts with Y or Z<program name >. and click on create button.

  • Enter the Title and select the attribute type as Executable.


Source Code




REPORT  ZTEST_MACRO.


DATA RES TYPE 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.

Input



  • Click on Execute.

Output


                              more information............



No comments:

Post a Comment