Application Development and Automation 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: 
Read only

function modules & subroutines

Former Member
0 Likes
505

what is the difference between function module & subroutine?

3 REPLIES 3
Read only

former_member191735
Active Contributor
0 Likes
473

Function modules are global and you can create them as remote function module but not the subroutines. Subroutines are program dependent...

Read only

Former Member
0 Likes
473

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.

Hope this helps.

Thanks

Sanjeev Kumar

Read only

Former Member
0 Likes
473

Hi,

These are 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.

Thanks,

Nanda