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
566

Dear All,

What are the precautions to be taken while writing a new macro in TRMAC table?

Please mention a scenario where the usage of macro is apt.

Regards,

Prosenjit.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
539

Hi,

macros are like #include in c programs.

Macros can only be used in the program the are defined in and only after the

definition.

Macros can take max 9 parameters.

Macros are expanded at compilation / generation.

In general:

A MACRO is more or less an abbreviation for some lines of code that are used

more than once or twice.

A FORM is a local subroutine (which can be called external).

A FUNCTION is (more or less) a subroutine that is called external.

Since debugging a MACRO is not really possible, prevent the use of them

(I've never used them, but seen them in action).

If the subroutine is used only local (called internal) use a FORM.

If the subroutine is called external (used by more than one program) use a

FUNCTION.

Success and keep in mind that the screw up from a macro can cause a lot of

work (more than the creation of a form),

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db972835c111d1829f0000e829fbfe/content.htm

see this link .

it will useful for you.

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.

*reward points.

Edited by: jeevitha on May 8, 2008 10:29 AM

3 REPLIES 3
Read only

Former Member
0 Likes
539

Hi,

macros are like #include in c programs.

These are local to program.

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db972835c111d1829f0000e829fbfe/content.htm

see this link .

it will useful for you.

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.

*reward points.

Read only

Former Member
0 Likes
540

Hi,

macros are like #include in c programs.

Macros can only be used in the program the are defined in and only after the

definition.

Macros can take max 9 parameters.

Macros are expanded at compilation / generation.

In general:

A MACRO is more or less an abbreviation for some lines of code that are used

more than once or twice.

A FORM is a local subroutine (which can be called external).

A FUNCTION is (more or less) a subroutine that is called external.

Since debugging a MACRO is not really possible, prevent the use of them

(I've never used them, but seen them in action).

If the subroutine is used only local (called internal) use a FORM.

If the subroutine is called external (used by more than one program) use a

FUNCTION.

Success and keep in mind that the screw up from a macro can cause a lot of

work (more than the creation of a form),

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db972835c111d1829f0000e829fbfe/content.htm

see this link .

it will useful for you.

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.

*reward points.

Edited by: jeevitha on May 8, 2008 10:29 AM

Read only

Former Member
0 Likes
539