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

DIFFERENCE

Former Member
0 Likes
685

WHAT IS THE DIFFERENCE BETWEEN <u><i>FUNCTION MODULE</i></u> AND <u><i>SUBROUTINE</u></i>

6 REPLIES 6
Read only

Former Member
0 Likes
659

HI,

<b>function module:</b>

1)this we will define globally(in tcode se37)

<b>subroutiene:</b>

1)the we will define with in the program,we can call it from the same program or some other program.

rgds,

bharat.

Read only

Former Member
0 Likes
659

Hi madan,

In contrast to normal subroutines function modules have uniquely defined interface. Sub routines do not return values.

Sub routines do not return exceptions.

Sub routines cannot be tested independently.

Declaring data as common parts is not possible for function modules.

Function modules are stored in a central library.

Reward points if helpful!

Kiran

Read only

Former Member
0 Likes
659

A Function Module is accessed via a Call command where parameters and tables can be passed and changed. The calling program is exited and execution occurs in the Function Module. Then it returns back to the FM after execution.

A subroutine is part of the main program, or in an Include to that program. Parameters can be defined globally in the calling programs. IOn a function module the parameters are defined in both the calling program and the FM.

Please reward points if helpful.

Message was edited by:

Tom M.

Read only

Former Member
0 Likes
659

Hi,

1) Fn module has its own editor.

2) Main diff is calling program and subroutine will share header line of global tables.

But calling program and fn module will not share. Fn.module creates its own.

3) Exception handling is possible in fn.module.

4) RFCs are possible

etc.,

Regards,

Subbu

Read only

Former Member
0 Likes
659

Subroutines:

1) We create subroutine using PERFORM, write the code between FORM...ENDFORM.,

2) Subroutine is created in Main program, in most of the cases

3) Passing parameters is bit complex

4) Passing tables is also bit complex

5) No return value

6) There is no Remote calling using subroutine

Function module:

1) Function modules are independent of the calling program.

2) They are stored in the Function Groups

3) Passing parameters is easy, they contain, Import, Export, Changing parameters

4) Passing Internal table is easy

5) Types of function modules are Normal/ Remote/ Update function module

6) Supports data encapsulation

Bye,

KC

Read only

Former Member
0 Likes
659

<b>Subroutines</b> are local modularization.you can use subroutines to write functions repeatedly within a program.you can define subroutines in any abap program.

<b>Functional modules</b> are global modularization.FM contain functions that are used in same form by many different programs.