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 between subroutines and Function Madule

Former Member
0 Likes
722

Hello all

What is difference between subroutines and Function Madule and how many types of functional madules are there

5 REPLIES 5
Read only

former_member156446
Active Contributor
0 Likes
681

In contrast to normal subroutines function modules have uniquely defined interface. Declaring data as common parts is not possible for function modules. Function modules are stored in a central library.

http://www.allinterview.com/showanswers/29188.html

Read only

Former Member
0 Likes
681

Hi,

Function Modules :

Function modules are global for all programd and all clients.

Function modules are accessed by same R/3 another R/3 and non R/3 systems also.

Function modules should return a value(more than one also)

Function modules are used at Module pool programs, BDCs, Scripts and smart forms.

Subroutines :

Sub routines doesn't return any values.

Sub routines in one R/3 can't be accessed by another R/3 systems.

Sub routines for local programs and current client only.

Reward if useful,

Regards,

Swetha.

Read only

Former Member
Read only

prasanth_kasturi
Active Contributor
0 Likes
681

hi,

The major differences between function modules and subroutines are the following:

Function modules have a special screen used for defining parameters-parameters are not defined via ABAP/4 statements.

tables work areas are not shared between the function module and the calling program.

Different syntax is used to call a function module than to call a subroutine.

Leaving a function module is accomplished via the raise statement instead of check, exit, or stop.

Read only

Former Member
0 Likes
681

hi,

A subroutine is a reusable section of code. It is like a mini-program that can be called from another point in your program. Within it you can define variables, execute statements, compute results, and write output. To define a subroutine, use the form statement to indicate the start of a subroutine, and use endform to indicate the end of the subroutine. The name of a subroutine cannot exceed 30 characters.

To call a subroutine use the perform statement.

subroutines cannot be nested inside of events.

global variables are defined outside of a subroutines using data statements or Tables.

Function Module : It is very similar to an external subroutine in these ways:

u2022Both exist within an external program.

u2022Both enable parameters to be passed and returned.

u2022Parameters can be passed by value, by value and result, or by reference.

The major differences between function modules and external subroutines are the following:

u2022Function modules have a special screen used for defining parameters-parameters are not defined via ABAP/4 statements.

u2022tables work areas are not shared between the function module and the calling program.

u2022Different syntax is used to call a function module than to call a subroutine.

u2022Leaving a function module is accomplished via the raise statement instead of check, exit, or stop.

A function module name has a practical minimum length of three characters and a maximum length of 30 characters. Customer function modules must begin with Y_ or Z_. The name of each function module is unique within the entire R/3 system.

pls reward if helpful.