Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Macros?

Former Member
0 Likes
590

Why do we need to define macros at times. is it of any use

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
556

Hi,

Macro can be used when you want to execute a particular code again and again. It is generally used for the calculation purpose.

for example

DEFINE calculate.

&1 = &2 + &3.

END-OF-DEFINITION.

DATA: l_var1 TYPE i,

l_var2 TYPE i,

l_var3 TYPE i.

Loop at itab.

calculate itab-var1 itab-var2 itab-var3.

endloop.

4 REPLIES 4
Read only

Former Member
0 Likes
556

Hi,

Macros are used for code modularization.

The main advantage of macro is that it can be stored in the table TRMAC, and can be used by any program.

Regards,

George

Read only

former_member156446
Active Contributor
0 Likes
556

I once had a requirement.. where I was writing data to file... and the req demanded that the quant fields need to show a space rather than 0.00 when empty... for that I wrote a macro and that solved the problem...

Read only

Former Member
0 Likes
557

Hi,

Macro can be used when you want to execute a particular code again and again. It is generally used for the calculation purpose.

for example

DEFINE calculate.

&1 = &2 + &3.

END-OF-DEFINITION.

DATA: l_var1 TYPE i,

l_var2 TYPE i,

l_var3 TYPE i.

Loop at itab.

calculate itab-var1 itab-var2 itab-var3.

endloop.

Read only

Former Member
0 Likes
556

Hi Puneeth,

Modularization is done by using macros.

we can written reusuable code in Macros .

for ex: we can build field catalog using Macros ...

Macros reduces the coding effort.

Hope it hepful .

Thanks

Lalitha.