2007 Dec 21 2:50 AM
2007 Dec 21 3:11 AM
Macro
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.
The following statement block defines a macro :
DEFINE .
END-OF-DEFINITION.
Macros do not belong to the definition part of the program. This means that the DEFINE...END-OF-DEFINITION block is not interpreted before the processing blocks in the program. At the same time, however, macros are not operational statements that are executed within a processing block at runtime. When the program is generated, macro definitions are not taken into account at the point at which they are defined
A macro definition inserts a form of shortcut at any point in a program and can be used at any subsequent point in the program. As the programmer, you must ensure that the macro definition occurs in the program before the macro itself is used. Particular care is required if you use both macros and include programs, since not all include programs are included in the syntax check (exception: TOP include).
REPORT ZMACRO.
DATA: RESULT TYPE I,
N1 TYPE I VALUE 5,
N2 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 4 + 3.
OPERATION 2 ** 7.
OPERATION N2 - N1.
The produces the following output:
The result of 4 + 3 is 7
The result of 2 ** 7 is 128
The result of N2 - N1 is 1
Check this link for more details.
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db972835c111d1829f0000e829fbfe/content.htm
Regards,
Maha
2007 Dec 21 3:04 AM
macros are a way of using repeated chunks of abap code. have a look at table TRMAC...this hold some macros.....they are useful if you have lots of repetituion of partuclar lines of code which aren't worth putting in a form.
BREAK is an example. If in your abap you put BREAK <your userid> . The macro will generate code to only break for your user_id.
BREAK 000 * USER specific BREAK-POINT
BREAK 001 if sy-uname = '&1'
BREAK 002 break-point
BREAK 003 endif
2007 Dec 21 3:06 AM
macro is kind of a function module...
1. define macro
2. call where ever needed..
2007 Dec 21 3:11 AM
Macro
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.
The following statement block defines a macro :
DEFINE .
END-OF-DEFINITION.
Macros do not belong to the definition part of the program. This means that the DEFINE...END-OF-DEFINITION block is not interpreted before the processing blocks in the program. At the same time, however, macros are not operational statements that are executed within a processing block at runtime. When the program is generated, macro definitions are not taken into account at the point at which they are defined
A macro definition inserts a form of shortcut at any point in a program and can be used at any subsequent point in the program. As the programmer, you must ensure that the macro definition occurs in the program before the macro itself is used. Particular care is required if you use both macros and include programs, since not all include programs are included in the syntax check (exception: TOP include).
REPORT ZMACRO.
DATA: RESULT TYPE I,
N1 TYPE I VALUE 5,
N2 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 4 + 3.
OPERATION 2 ** 7.
OPERATION N2 - N1.
The produces the following output:
The result of 4 + 3 is 7
The result of 2 ** 7 is 128
The result of N2 - N1 is 1
Check this link for more details.
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db972835c111d1829f0000e829fbfe/content.htm
Regards,
Maha
2007 Dec 21 3:40 AM