Application Development 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: 

about macros

Former Member
0 Kudos

Hi what is the use of macros in ABAP programming ?

What is the role of place holders in macros ?

2 REPLIES 2

Former Member
0 Kudos

Macros are a form of shortening your code by creating a "verb" and passing it 1 or more parameters to do redundant code. This example from the F1 on DEFINE is a simple one, but show the concept.


DEFINE INCREMENT. 
  ADD 1 TO &1. 
END-OF-DEFINITION. 

DATA: NUMBER TYPE I VALUE 1. 
... 
INCREMENT NUMBER. 

In this case the macro (INCREMENT) is defined to add one to any field you pass it. Here NUMBER is defined as an interger with a value of 1.

Now the verb INCREMENT can be used to add to the field passed.

Executing this program, after INCREMENT NUMBER line, NUMBER will have the value of 2.

This is a simple example. The place I've seen this concept used the most is in HR modules.

Former Member
0 Kudos

hi ,

If you want to reuse the same set of statements more than once in a program, you can include them in a macro. For example, this can be useful for long calculations or complex WRITE statements. You can only use a macro within the program in which it is defined, and it can only be called in lines of the program following its definition.

Yes, you can get the same results without using them, but will have to explicitly put the code each time you want to perform the operation it does.

Using Macros is a Programming Utility to avoid repetitive coding in a Program.

The Macros used in HR reports tied to PNP are stored in the table TRMAC. Go into SE16 and display the Table contents.

check this also...

http://help.sap.com/saphelp_nw04/helpdata/en/f1/0a55f9e09411d2acb90000e829fbfe/content.htm

regards,

venkat.

Edited by: venkat appikonda on Mar 18, 2008 7:49 PM