MACROS

MACROS:-
         Macros are used to perform the arithmetical operations. Macros can take up to 9 place holders. (&1, &2, -- - &9). If you want to maintain the same set of statements more than one location of the same program instead of this we maintain those statements in macro definition later we call the same macro definition from different locations of the same program.


Syntax of calling the macro: -
<macro name> <place holder1 value> <place holder 2 value>.

Note: - In macros definition should be the first and calling should be the next.

PROGRAM:
*&---------------------------------------------------------------------*
*& Report  ZR_MACROS
*&
*&---------------------------------------------------------------------*

REPORT ZR_MACROS.
Typesbegin of ty_t001,
       Bukrs 
type t001-bukrs,
       Butxt 
type t001-butxt,
       Ort01 
type t001-ort01,
       
End of ty_t001.
Datawa_t001 type ty_t001,
      it_t001 
type table of ty_t001.
Define fill_tab.
 wa_t001
-bukrs &1.
 wa_t001-butxt 
&2.
 wa_t001-ort01 
&3.
 
Append wa_t001 to it_t001.
 
Clear wa_t001.
End-of-definition.

Fill_tab '1000' 'TCS' 'HYD'.
Fill_tab '2000' 'IBM' 'CHE'.
Loop at it_t001 into wa_t001.
 
Write/ wa_t001-bukrswa_t001-butxtwa_t001-ort01.
 
ENDLOOP.