Macro VS Subroutine(ABAP)
2006-07-19 11:25
316 查看
Modularization technique
1. Source code modules(expanded at compilation:编译时展开,没有压栈弹栈操作,系统开销小!)
a. Macros(Macros are a text substitute for the translation phase,相当于字符替换)
b. Include Programs
2. Procedures(expanded at runtime: 运行时展开,编译时和主程序是两个部分,运行时,将要调用的程序压栈,然后弹栈调用。)
a. Subroutine
b. Function Modules
c. Methods
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.
Notes: that means Macro is expanded at complication but subroutines are 'expanded' at runtime.
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.
Functions are just like FORMs, but are intended to be called external.
Some differences between FUNCTIONs and FORMs:
The name of a FORM must be unique within the program (two programs can have different FORMs with the same name). A FORM is intended to be called internal (from within the program, however by a 'trick' you can call them external).
The name of a FUNCTION has to be unique throughout the system. A FUNCTION is intended to be called external (and is thus shared by 'many' programs).
The latter is more important for programmers and maintenance. Since a FUNCTION is called external, it is important to keep the interface (parameters) the same. The interface of a FORM (which is intended to be called internal) is check when debugging a program (but it is only checked within the program that is debugged). So if the interface of a FORM is changed, but the call to the FORM (perform ) is not, the debugger will notice this and issue an error message.
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.
1. Source code modules(expanded at compilation:编译时展开,没有压栈弹栈操作,系统开销小!)
a. Macros(Macros are a text substitute for the translation phase,相当于字符替换)
b. Include Programs
2. Procedures(expanded at runtime: 运行时展开,编译时和主程序是两个部分,运行时,将要调用的程序压栈,然后弹栈调用。)
a. Subroutine
b. Function Modules
c. Methods
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.
Notes: that means Macro is expanded at complication but subroutines are 'expanded' at runtime.
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.
Functions are just like FORMs, but are intended to be called external.
Some differences between FUNCTIONs and FORMs:
The name of a FORM must be unique within the program (two programs can have different FORMs with the same name). A FORM is intended to be called internal (from within the program, however by a 'trick' you can call them external).
The name of a FUNCTION has to be unique throughout the system. A FUNCTION is intended to be called external (and is thus shared by 'many' programs).
The latter is more important for programmers and maintenance. Since a FUNCTION is called external, it is important to keep the interface (parameters) the same. The interface of a FORM (which is intended to be called internal) is check when debugging a program (but it is only checked within the program that is debugged). So if the interface of a FORM is changed, but the call to the FORM (perform ) is not, the debugger will notice this and issue an error message.
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.
相关文章推荐
- ABAP--关于abap的subroutines的几个注意点
- arguments for subroutine in Perl
- SAP BSP vs Web Dynpro ABAP
- Info Package ABAP routine
- ABAP vs Java, 蛙泳 vs 自由泳
- vs 2015 编译cocos2dx 报错C1189 #error: Macro definition of snprintf conflicts with Standard Library func
- ABAP:截取字符串(Start Routine)
- template vs macro
- VS 2015 编译一些库的时候,出现 error “fatal error C1189: #error: Macro definition of snprintf conflicts with St
- MYSQL execution time comparison(MYSQL 运行时间比较)-subselect vs select from 2 table
- subroutine has the same name with build_in functions
- Macro vs Proc
- 执行perl时出现Undefined subroutine
- Inline vs macro
- [abap] [sample] ALV with subtotal
- vs 2015 编译cocos2dx 报错C1189 #error: Macro definition of snprintf conflicts with Standard Library func
- join update vs sub-selects update
- Some MACRO In VS Project Setting
- vs macro shortcuts
- ABAP--关于abap的subroutines的几个注意点