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

Diff between MACRO and Include programs

Former Member
0 Likes
879

Hi Experts,

what is the Diff between MACRO and Include programs ?

Thanks in Advance

Raj

4 REPLIES 4
Read only

alejandro_bindi
Active Contributor
0 Likes
684

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.

Read only

Former Member
0 Likes
684

Check out this thread

Read only

Former Member
0 Likes
684

Macros and Includes serves the same purpose. However you can use a Macro local to that program where as Include can be used globally.

Read only

Clemenss
Active Contributor
0 Likes
684

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