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

diff bt sub-routine n Fn Modules

Former Member
0 Likes
1,078

hi everyone,

can anyone explain exactly what is the difference between a sub-routine and a function module

in which scenario can we use them exactly, an example would be welcome.

Thanks in Advance,

rama

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,042

Hi,

A Subroutine can only be called within a program, will be destroyed/out of scope at outside the program, cannot be called from any other program.

Where as a Function module is availabe in SAP repository and can used in any no. of programs. It is having Scope in entire SAP repository. It can be declared globally and can be used in any program.

regards

Rakesh

  • pls don't forget to reward points if u'r problem is solved

10 REPLIES 10
Read only

suresh_datti
Active Contributor
0 Likes
1,042

A subroutine can only be called from a program while a function module can be executed as a standalone..

~Suresh

Read only

Former Member
0 Likes
1,042

hi ,

Function module existed in global lever where as subroutine is related to program.

and exceptions rising is also possible in function module but not in subroutine.

Read only

Former Member
0 Likes
1,042

hi,

suroutine- will be used inside a prog

FM -will be used globally

siva

Read only

Former Member
0 Likes
1,043

Hi,

A Subroutine can only be called within a program, will be destroyed/out of scope at outside the program, cannot be called from any other program.

Where as a Function module is availabe in SAP repository and can used in any no. of programs. It is having Scope in entire SAP repository. It can be declared globally and can be used in any program.

regards

Rakesh

  • pls don't forget to reward points if u'r problem is solved

Read only

Former Member
0 Likes
1,042

FM's are global. Also client independant. But Sub routines can not.

Cheers.

Read only

0 Likes
1,042

Even subroutines are client independant .

Read only

Former Member
0 Likes
1,042

Function Module can be run individually using SE37 transaction.But subroutine cant be run individually.

you can't catch exceptions in subroutines. But in Function modules you can.

Read only

former_member508729
Active Participant
0 Likes
1,042

Hi,

subroutine is program specific logical group of abap sentence which has using changing and tables as parameters which achieves a particular functioanlity.

FM is at global levels means u can call same FM in different programs and parameters are import export, tables and exceptions etc. u have to pass import and export parameters to FM.

Also in case of subroutines u can call it from other program like,

Perform sub_name in program ( Program name ) if found.

Regards

Ashutosh

Reward points if helpful

Read only

Former Member
0 Likes
1,042

thanks a lot for the replies friends,

i want to reward points to all, but i could do it to only one guy

how can i do it to others

and i want to make sure bt one thing, subroutines are client-independent

and even though this thread is solved, i please request my friends to reply to this thread if at all any other difference is found

Cheers,

rama

Read only

0 Likes
1,042

Subroutines cannot be called in different server

where functional module can be remotely called in another server.....

Hop this is also a big difference...