2007 Apr 19 7:20 AM
In interview ince i had faced the following question.Please reply me for this:
What is the difference between Subroutine and Function Module???
2007 Apr 19 7:29 AM
Hi
Subroutines are attatched with program,
so if you use it in the same program its called internal subroutine which is called directly using perform
If you want to call subroutine which is present in diff. program, called EXTRENAL subroutine, you have to specify the Program name also in perform
Function module are present across the clients.
2007 Apr 19 7:22 AM
Hi,
Subroutine is a reusable piece of code which is used insdie a single program.
e.g.
anything between FORM ....ENDFORM
Function Module is a reusable piece of code which can be used across different programs.
e.g
CALL FM 'COMMIT_WORK'.
Best regards,
Prashant
2007 Apr 19 7:23 AM
A subroutine cant be accessed by all the programmes while FM can be accessed by all the programs...
A subroutine doesnt have exceptions while a FM can have exceptions
2007 Apr 19 7:23 AM
hi,
Function modules are procedures that are defined in function groups (special ABAP programs with type F) and can be called from any ABAP program. Function groups act as containers for function modules that logically belong together,Function modules allow you to encapsulate and reuse global functions in the R/3 System. They are stored in a central library,Unlike subroutines, you do not define function modules in the source code of your program.
Subroutines are procedures that you can define in any ABAP program and also call from any program. Subroutines are normally called internally, that is, they contain sections of code or algorithms that are used frequently locally. If you want a function to be reusable throughout the system, use a function module
reward points if it helps
Kishi.
2007 Apr 19 7:26 AM
Hi Reema,
Subroutines are program modules, which can be called from other ABAP/4 programs or within the same program. Mainly its used for Modularisation of Programs
<u>Internal Subroutin</u>es: The source code of the internal subroutines will be in the same ABAP/4 program as the calling procedure (internal call).
<u>External Subroutines</u>: The source code of the external subroutines will be in an ABAP/4 program other than the calling procedure.
In contrast to normal subroutines function modules have uniquely defined interface. Declaring data as common parts is not possible for function modules. Function modules are stored in a central library.
Regards
Avi..
2007 Apr 19 7:26 AM
Hi,
In contrast to normal subroutines function modules have uniquely defined interface. Declaring data as common parts is not possible for function modules. Function modules are stored in a central library.
Regards
Sudheer
2007 Apr 19 7:29 AM
Hi
Subroutines are attatched with program,
so if you use it in the same program its called internal subroutine which is called directly using perform
If you want to call subroutine which is present in diff. program, called EXTRENAL subroutine, you have to specify the Program name also in perform
Function module are present across the clients.
2007 Apr 19 7:37 AM
Hi,,
check if the following info is useful to you
A subroutine is a block of code introduced by FORM and concluded by ENDFORM.
FORM <subr> [USING ... [VALUE(]<pi>[)] [TYPE <t>|LIKE <f>]... ]
[CHANGING... [VALUE(]<pi>[)] [TYPE <t>|LIKE <f>]... ].
...
ENDFORM.
<subr> is the name of the subroutine. The optional additions USING and CHANGING define the parameter interface. Like any other processing block, subroutines cannot be nested. You should therefore place your subroutine definitions at the end of the program, especially for executable programs (type 1). In this way, you eliminate the risk of accidentally ending an event block in the wrong place by inserting a FORM...ENDFORM block.
Function module ::Function modules are procedures that are defined in function groups (special ABAP programs with type F) and can be called from any ABAP program. Function groups act as containers for function modules that logically belong together. You create function groups and function modules in the ABAP Workbench using the Function Builder.
Function modules allow you to encapsulate and reuse global functions in the R/3 System. They are stored in a central library. The R/3 System contains a wide range of predefined function modules that you can call from any ABAP program. Function modules also play an important role in database updates and in remote communications between R/3 Systems or between an R/3 System and a non-SAP system
2007 Apr 19 8:03 AM
Main thing is u can test the function module independently but not the subroutines.
Both these function modules and subroutines are similar to methods in OOPS.
The function modules are global calls where u can call the function modules from any program.
Whereas the subroutines called with in the program but we can make dynamic subroutines calls from other programs also.
Regards
Santhosh
Message was edited by:
santhosh ds
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |