05-21-2008 11:12 AM
what is the differenece between subroutines and function modules.
thanks
mouni
05-21-2008 12:20 PM
Hi,
The basic differences between those two is.....
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.
see this link for more info,,,,,
https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=differencebetweensubroutinesandfunction+modules&adv=false&sortby=cm_rnd_rankvalue
thanks
karthik
05-21-2008 11:15 AM
Hi,
Welcome to SDN.
The answer to your question can be easily found by searching the forum. I searched the ABAP General forum with the term "differenece between subroutines and function modules" and found loads of answers.
You may want to do the same.
Regards,
Nick
05-21-2008 11:16 AM
Hi,
Function Modules :
Function modules are global for all programd and all clients.
Function modules are accessed by same R/3 another R/3 and non R/3 systems also.
Function modules should return a value(more than one also)
Function modules are used at Module pool programs, BDCs, Scripts and smart forms.
Subroutines :
Sub routines doesn't return any values.
Sub routines in one R/3 can't be accessed by another R/3 systems.
Sub routines for local programs and current client only.
<removed_by_moderator>
Regards,
Swetha.
Edited by: Julius Bussche on Aug 20, 2008 10:27 PM
05-21-2008 11:24 AM
hi,
Subroutines are program modules, which can be called from other ABAP/4 programs or within the same program.
If you want a function to be reusable throughout the system, use a function module. Function modules allow you to encapsulate and reuse global functions in the R/3 System
Unlike subroutines, you do not define function modules in the source code of your program.
exceptions can be raised in functionmodule, the function modules can remote enabled.
<removed_by_moderator>
thanks and regards
Edited by: Julius Bussche on Aug 20, 2008 10:28 PM
05-21-2008 12:20 PM
Hi,
The basic differences between those two is.....
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.
see this link for more info,,,,,
https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=differencebetweensubroutinesandfunction+modules&adv=false&sortby=cm_rnd_rankvalue
thanks
karthik
08-20-2008 11:30 PM
You should have listened to Nick's good advice!!
Probably you were too busy managing different ID's...