‎2007 May 12 3:37 PM
Hi Experts,
what is the Diff between MACRO and Include programs ?
Thanks in Advance
Raj
‎2007 May 12 4:11 PM
A macro is not a program, but a kind of "subroutine" (similar to FORMs), here's an example:
* Macro Definition-------------------------------------------------*
* Application server File opening and reading.
DEFINE READ_DATASET_INPUT.
OPEN DATASET &1 FOR INPUT IN TEXT MODE.
IF SY-SUBRC NE 0.
PERFORM ERROR USING &3 SY-DATUM 'E' 'ZERRS' '101' &1
SPACE SPACE SPACE SPACE SPACE SPACE.
ELSE.
DO.
READ DATASET &1 INTO &2.
IF SY-SUBRC NE 0.
EXIT.
ELSE.
APPEND &2.
CLEAR &2.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET &1.
END-OF-DEFINITION.
* You call it like this on the program:
READ_DATASET_INPUT P_FILE T_MAIN G_PROGRAM.
From help: "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."
For modularization purposes, it's preferable to use Forms of Function modules.
<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db972835c111d1829f0000e829fbfe/content.htm">More on Macros</a>
An INCLUDE program is a non-executable program which generally has something complementary to the main program (for example type/data declarations or Form subroutines).
<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db973535c111d1829f0000e829fbfe/content.htm">More on INCLUDE</a>
Please award points if helpful.
‎2007 May 12 4:42 PM
‎2007 May 12 6:40 PM
Macros and Includes serves the same purpose. However you can use a Macro local to that program where as Include can be used globally.
‎2007 May 12 9:46 PM
Hi raj,
a macro is evaluated during compile time. The generated code can not be debugged. Just do not use macros. They make programs less transparent and difficult to understand in debug mode.
Regards,
Clemens