‎2008 Jun 18 9:38 AM
Hi experts,
can any one explain me the main differences between subroutines and function modules?
Thanks in advances.
‎2008 Jun 18 9:41 AM
Hi,
FM are created in Function Builder (SE37) and belong to a program of type Function Group. A FM has a parameter interface that includes EXCEPTIONS tab that can be used to declare exceptions that can be thrown by the FM. This can be checked using SY-SUBRC field after the FM call. Since they are defined in SE37, they are global and can be called by any program or FM in the same system or can also be called by a remote system, if declared as RFC enabled. Also, only FM can be used for updating database using UPDATE TASK.
Subroutines are defined as part of a program of type Executable, Module Pool, Include, Subroutine Pool and Function Group. They also have parameter interface that consists of USING CHANGING and TABLES (Obsolete) additions. They are not global, though they can be called from other programs or FM in the same system by supplying the program name to which belong in parentheses. They cannot be used for remote calls or updating database using UPDATE TASK.
Functionality-wise they do the same job i.e. they are called by a clling program with some parameters and they may or may not return a result.
The main differences between a function module and subroutine.
Function modules :
1. Function modules are global for all programd and all clients.
2. Function modules are accessed by same R/3 another R/3 and non R/3 systems also.
3. Function modules should return a value(more than one also)
4. Function modules are used at Module pool programs, BDCs, Scripts and smart forms.
Sub routines :
1. Sub routines doesn't return any values.
2. Sub routines in one R/3 can't be accessed by another R/3 systems.
3. Sub routines for local programs and current client only.
Regards,
Mahesh
‎2008 Jun 18 9:40 AM
hi,
Subroutienes cannot be executed alone where as fms can
subroutienes use program memory but fm use seperate memory space
regards
prasanth
‎2008 Jun 18 9:41 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
Thanks
Virkanth
‎2008 Jun 18 9:41 AM
Hi,
FM are created in Function Builder (SE37) and belong to a program of type Function Group. A FM has a parameter interface that includes EXCEPTIONS tab that can be used to declare exceptions that can be thrown by the FM. This can be checked using SY-SUBRC field after the FM call. Since they are defined in SE37, they are global and can be called by any program or FM in the same system or can also be called by a remote system, if declared as RFC enabled. Also, only FM can be used for updating database using UPDATE TASK.
Subroutines are defined as part of a program of type Executable, Module Pool, Include, Subroutine Pool and Function Group. They also have parameter interface that consists of USING CHANGING and TABLES (Obsolete) additions. They are not global, though they can be called from other programs or FM in the same system by supplying the program name to which belong in parentheses. They cannot be used for remote calls or updating database using UPDATE TASK.
Functionality-wise they do the same job i.e. they are called by a clling program with some parameters and they may or may not return a result.
The main differences between a function module and subroutine.
Function modules :
1. Function modules are global for all programd and all clients.
2. Function modules are accessed by same R/3 another R/3 and non R/3 systems also.
3. Function modules should return a value(more than one also)
4. Function modules are used at Module pool programs, BDCs, Scripts and smart forms.
Sub routines :
1. Sub routines doesn't return any values.
2. Sub routines in one R/3 can't be accessed by another R/3 systems.
3. Sub routines for local programs and current client only.
Regards,
Mahesh
‎2008 Jun 18 9:41 AM
check this
https://www.sdn.sap.com/irj/sdn/directforumsearch?threadid=&q=differencesbetweensubroutinesandfunction+modules%3F&objID=&dateRange=last90days&numResults=15
‎2008 Jun 18 9:41 AM
‎2008 Jun 18 9:41 AM
Hi,
1. FM are Global . Any program can use it.
where else for subroutines, we have to use the INCLUDE.
2. Most important -
FMs can be tested thru se37
whereas for testing subroutines, we have to write some abap code.
3. FMS have WELL DEFINED interface, and it can be documented for each parameter.
Whereas subroutines do not have such great facility.
4. FMs can be update task, RFC etc.
whereas subroutines are much limited.
Thanks
Vikranth
‎2008 Jun 18 9:42 AM
suppose u have one program..that program can use any function module which is existing...But it can use a subroutine...which is defined either inside this program or inside the include, which this program is having...
Reward points...if the abv ans is helpful
‎2008 Jun 18 9:43 AM
‎2008 Jun 18 9:47 AM
Hi,
Subroutines are dependent i.e they cannot exist without a program whereas FM are independent.
Subroutines doesn't return any values while FMs return values.
we use using, changing in case of subroutines while we use import export incase of FM.
Declaring data as common parts is not possible for function modules
Sub routines in one R/3 can't be accessed by another R/3 systems.
Thanks and regards.