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: 

difference between subroutines and functionmodules

Former Member
0 Kudos

Hi everybody,

Can anybody help me out in knowing technical diffrences between subroutines and function modules

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi, somebody has mentioned the difference, let me add something in my opinion.

Yeah, I agree with vinod, both of them can be called from other application, so the mainly difference is not here.

In my opinion, the function module mechansim provide the developer a common way or tools (se37) to define the function you intent, the status is just same with class (se24). yeah, you can define them in a include file or an application, but every developer will write the define code in their own style, but through the common tools, all of us do in the same way.

In additon, through the tools, there are also some functions can be achieved in function module, but subroutine can't. E.G. remotely call enable.

So in the definition view, you can treat them as two way, one is manually, the other is wizard.

In function feature view, absolutely the function module is better than subrountine.

That's my opinion in this topic.

hehe, hope you feel it is hopeful

Thanks

5 REPLIES 5

Vinod_Chandran
Active Contributor
0 Kudos

Both Subroutine and Function modules are used for modularisation and reuse.

The visibility of subroutine is inside the program where you have defined (Still you can call this from another program).

But the function module is defined in the repository and can be called from all the programs.

Thanks

Vinod

0 Kudos

hai vinod,

thanks for the reply.

Subroutines are also client independent.Isn't it. they can also be called in all other programs, same as function modules.

Can you explain me more elobarate.

thanks chandrika

0 Kudos

Yes. Subroutines are client independent.

Subroutine is a part of a program and program is client independent.

Same as function modules, subroutines are also called from another program using the command

PERFORM <subroutine name> IN PROGRAM <program name> USING....

Please see the following post for more information

Thanks

Vinod

Former Member
0 Kudos

Hi, somebody has mentioned the difference, let me add something in my opinion.

Yeah, I agree with vinod, both of them can be called from other application, so the mainly difference is not here.

In my opinion, the function module mechansim provide the developer a common way or tools (se37) to define the function you intent, the status is just same with class (se24). yeah, you can define them in a include file or an application, but every developer will write the define code in their own style, but through the common tools, all of us do in the same way.

In additon, through the tools, there are also some functions can be achieved in function module, but subroutine can't. E.G. remotely call enable.

So in the definition view, you can treat them as two way, one is manually, the other is wizard.

In function feature view, absolutely the function module is better than subrountine.

That's my opinion in this topic.

hehe, hope you feel it is hopeful

Thanks

0 Kudos

Hi Chandrika,

You opened two posts with the same question. Can you please close one or both(if answered)? Here is my reponse in the other post.

-


Hi Chandrika,

I was looking at the responses given here for your question. I am sorry but I have to disagree with Karthik here. Client dependency or client independent does not come into picture in this discussion at all. Any piece of code(subroutines, function modules or programs etc) is client independent, which means if you write a piece of code in one client, then that is visible and can be executed from anywhere. Whether they work on client independent tables or client dependent tables, is up to the purpose of the code. There is no restriction that you cannot select data from client independent tables in sub routines or function modules.

Also, another point made by Karthik that subroutines are specific to a program is not entirely true. If the subroutine logic and the parameters suit your purpose, you can always call a subroutine of another program in your program, even though it is rarely used.

The intended purpose of subroutines is to provide more modularization and readability, but added advantage is that it can also be used for reusability.

The intended purpose of function modules is more for reusability and encapsulation. So if you want to encapsulate certain reusable logic and provide a standard interface to the outside world. Please note that the primary stress here is on reusability and encapsulation and not on modularization, whereas in subroutines that is the primary purpose, but has the others as secondary benefits.

A function module exists as an independent executable piece of code, but a subroutine can only be executed within a main program. So the context in which they are executed during runtime are different.

If these answers give you enough insight into the two constructs, please rewarad and close the post.

Regards,

Srinivas