‎2008 Apr 28 1:17 PM
‎2008 Apr 28 1:20 PM
HII
Macros can only be used in the program the are defined in and only after the definition are expanded at compilation / generation.
Subroutines (FORM) can be called from both the program the are defined in and other programs .
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 . 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.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 28, 2008 4:51 PM
‎2008 Apr 28 1:19 PM
Hi Jiccs,
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.
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).
Macros Cannot be Debugged.
Subroutines (FORM) can be called from both the program the are defined in and other programs ('perform
' of 'perform in program ').
Subroutines can take any amount of parameters.
Subroutines are 'expanded' at runtime.
A FUNCTION is (more or less) a subroutine that is called external.
Subroutines Can be Debugged.
Regards,
Sunil
‎2008 Apr 28 1:20 PM
HII
Macros can only be used in the program the are defined in and only after the definition are expanded at compilation / generation.
Subroutines (FORM) can be called from both the program the are defined in and other programs .
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 . 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.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 28, 2008 4:51 PM
‎2008 Apr 28 1:22 PM
Subroutine is a block of code you would execute with a PERFORM.
A Macro is a section of code that is normally redundent and you can save your self some work by using it to implement the code with different parameters.
Macro Example
*_________________________________________________ Macros
DEFINE filefrom.
* &1 file field name
* &2 screen field name
* &3 radio group name
* &4 modif id name
* text-305 = From
* text-306 = File
* text-307 = Screen
selection-screen begin of line.
selection-screen comment 1(10) text-305 modif id &4.
selection-screen comment 14(05) text-306 modif id &4.
selection-screen position 20.
parameters: &1 radiobutton group &3 default 'X' modif id &4.
selection-screen comment 24(06) text-307 modif id &4.
selection-screen position 31.
parameters: &2 radiobutton group &3 modif id &4.
selection-screen end of line.
END-OF-DEFINITION.
*
*
*
*
* And the use of it.
*
*
SELECTION-SCREEN: BEGIN OF BLOCK blk3 WITH FRAME TITLE text-003.
filefrom p_cmtf p_cmts grp3 new. " <== Macro being used will generate the above code using the 4 parameter passed
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(10) text-361 MODIF ID new.
SELECTION-SCREEN POSITION 12.
PARAMETERS: p_comm(132) TYPE c LOWER CASE MODIF ID new.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK blk3.
*
*
*
‎2008 Apr 28 1:22 PM
hi,
Macros can only be used in the program the are defined in and only after the definition are expanded at compilation / generation. A macro is more or less an abbreviation for some lines of code that are used more than once or twice. Since debugging a MACRO is not really possible, prevent the use of them.
Subroutines can be called from both the program the are defined in and other programs . A FORM is a local subroutine (which can be called external). A FUNCTION is (more or less) a subroutine that is called external. If the subroutine is used only local (called internal) use a FORM to call it. If the subroutine is called externally use a Function to call it.
regards,
madhu
‎2008 Apr 28 1:25 PM
Macros do NOT evaluate the values passed during run-time. This creates the effect of abbreviating code. It is as if the compiler writes the code over and over again. This is the reason why you cant debug macros.
Subroutines evaluate their values during run-time. Memory is alloted.