Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

hi

Former Member
0 Kudos

what is the differenece between subroutines and function modules.

thanks

mouni

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

5 REPLIES 5

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

You should have listened to Nick's good advice!!

Probably you were too busy managing different ID's...