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

Which is faster- Function Module or a subroutine

Former Member
0 Likes
1,541

Hi Experts,

I have a question. I want to know that in terms of execution time which is faster -

a Function Module being used in a program or a subroutine of any other program being called in a program.

Kindly let me know your comments on this.

Points will be suitably rewarded to useful answers.

Thanks in advance.

Regards,

Himanshu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,305

Subroutine is faster than the Function modules. This is because subroutine is a part of the main program or subroutine pool program and it does not take much time during runtime but for function modules, system accesses whole Function group associated to it which cause the bad performance and runtime is more compared to same code in a subroutine.

9 REPLIES 9
Read only

Former Member
0 Likes
1,306

Subroutine is faster than the Function modules. This is because subroutine is a part of the main program or subroutine pool program and it does not take much time during runtime but for function modules, system accesses whole Function group associated to it which cause the bad performance and runtime is more compared to same code in a subroutine.

Read only

Former Member
0 Likes
1,305

Function Module faster .

Read only

Former Member
0 Likes
1,305

Hi Himanshu,

Both will require the same time, if the Import, Export parameters are the same & code is same.

The reason of using a FM instead of subroutine is for REUSE. You can use the same FM across different programs whereas subroutine is restricted to use only within the same program.

Best regards,

Prashant

Read only

varma_narayana
Active Contributor
0 Likes
1,305

Hi Himanshu..

Always better to call FMs instead of External Subroutines.

SAP will not recommend to use External subroutines.

So FMs will be fast compared to External subroutines.

<b>reward if Helpful.</b>

Read only

kiran_k8
Active Contributor
0 Likes
1,305

Himanshu,

I think it is function module which is faster when compared to Subroutines.Looking forward to SDN experts replies too.

Thanks,

K.Kiran.

Read only

paruchuri_nagesh
Active Contributor
0 Likes
1,305

hi

function modules increases u r program performances

when comparing with external sub routines

but subroutines provides readability & modularization

function modules provides reusability & encapsulation

function module gets process in function group

subroutine gets process in calling program thats the main difference between them

regards

Nagesh.Paruchuri

Read only

Former Member
0 Likes
1,305

Hi,

<b>Subroutines</b>

Subroutines are principally for local modularization, that is, they are generally called from the program in which they are defined. You can use subroutines to write functions that are used repeatedly within a program. You can define subroutines in any ABAP program.

<b>Function Modules</b>

Function modules are for global modularization, that is, they are always called from a different program. Function modules contain functions that are used in the same form by many different programs. They are important in the R/3 System for encapsulating processing logic and making it reusable. Function modules must be defined in a function group, and can be called from any program.

<i>Subroutines executes faster than the fn modules because subroutines are defined within the program and they are executed after they have been called whereas the when u call a fn module, it is defined globally and it is accessed through a fn group in which they are stored. ALso the fn group should be active at the time of calling.</i>

Please reward if helpful.

Read only

Former Member
0 Likes
1,305

subroutines are faster than function modules.

Read only

Former Member
0 Likes
1,305

Thanks all for your replies