‎2008 May 08 5:36 AM
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.
‎2008 May 08 5:56 AM
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
‎2008 May 08 5:55 AM
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.
‎2008 May 08 5:56 AM
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
‎2008 May 08 5:59 AM
Hi,
Check the theard
https://forums.sdn.sap.com/click.jspa?searchID=11558868&messageID=4767053
Regards
Kiran Sure