Saturday, February 12, 2011

Macros Example (ABAP Programming)

DATA: RESULT TYPE I,
      a TYPE i value 15,
      b TYPE i value 6.

DEFINE OPERATION.
    RESULT = &1 &2 &3.
    OUTPUT &1 &2 &3 RESULT.
END-OF-DEFINITION.

DEFINE OUTPUT.
    WRITE:/ 'The result of &1 &2 &3 is', &4.
END-OF-DEFINITION.
 
  OPERATION a + b.
  OPERATION a - b.
  OPERATION a * b.



Output:

The Result of a + b is 21
The Result of a - b is 9
The Result of a * b is 90

2 comments: