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

subroutine

Former Member
0 Likes
670

hi to all

can u pls tell the difference between external subroutines and function modules .

points will be rewarded fotr good answers

6 REPLIES 6
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
646

HI,

One of the technical differece would be we cannot have EXCEPTIONS for subroutine's where as FM's can have EXCEPTIONS.

Another difference would be Subroutine's cannot have OPTIONAL parameters where as FM's can have.

Regards,

Sesh

Read only

Former Member
0 Likes
646

hi,

Function modules are procedures that are defined in function groups (special ABAP programs with type F) and can be called from any ABAP program. Function groups act as containers for function modules that logically belong together,Function modules allow you to encapsulate and reuse global functions in the R/3 System. They are stored in a central library,Unlike subroutines, you do not define function modules in the source code of your program.

Subroutine is a generic term given to all

reusable program codes.

Subroutines are procedures that you can define in any ABAP program and also call from any program. Subroutines are normally called internally, that is, they contain sections of code or algorithms that are used frequently locally. If you want a function to be reusable throughout the system, use a function module

<b>Reward Useful Points</b>

Siva

Read only

Former Member
0 Likes
646

Hi,

Function modules are procedures that are defined in function groups (special ABAP programs with type F) and can be called from any ABAP program.

Function groups act as containers for function modules that logically belong together.

Function modules allow you to encapsulate and reuse global functions in the R/3 System.

Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the Function Builder.

Subroutines are procedures that you can define in any ABAP program and also call from any program. Subroutines are normally called internally, that is, they contain sections of code or algorithms that are used frequently locally.

As mentioned, both forms and FMs are reusable modularization units. To distinguish we generally say that forms are used for internal modularization and FMs are used for external modularization.

To decide on which to implement, consider whether you need the content to be used just for a limited program or wheteher it can be called from many independent programs. For the first purpose it is better to implement a form whereas for the second we implement an FM.

However, ABAP does not isolate the usage context. That is; you can call a form from another program within whose code the form is not actually implemented. However, this requires attention since the form may utilize global variables.

The same issue holds for FMs. FMs are encapsulated in function groups and function groups may have global variables that can be globally used by all FMs inside it.

Subroutines are loacl to a progarm.. It cant be extended to other program.

But Function Modules are similar to subroutines but are global in view and can be used in many program.

Subroutine have three types.

pass by value, pass by reference and pass by value and reference similar to pointers but not exactly the same.

Function modules are used in BDC , BAPI etc..

Also there are standard FMs which can be used.

Regards,

Priyanka.

Read only

Former Member
0 Likes
646

HI,

YOU CANOT EXECUTE EXTERNAL SUBROUTINES AND CANOT RAISE ANY TYPE OF EXCEPTIONS AND THEY CAN BE USED ONLY IN INTERNAL SESSIONS OF AABAP MEMORY

WHERAS YOU CAN EXECUTE AND RAISE EXCEPTIONS IN FM AND YOU CAN ASSES THEM GLOBALLY

Read only

Former Member
0 Likes
646

Hi Sunil,

Function modules are procedures that are defined in function groups (special ABAP programs with type F) and can be called from any ABAP program.

Function groups act as containers for function modules that logically belong together.

Function modules allow you to encapsulate and reuse global functions in the R/3 System.

Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the Function Builder.

Subroutines are procedures that you can define in any ABAP program and also call from any program. Subroutines are normally called internally, that is, they contain sections of code or algorithms that are used frequently locally.

As mentioned, both forms and FMs are reusable modularization units. To distinguish we generally say that forms are used for internal modularization and FMs are used for external modularization.

To decide on which to implement, consider whether you need the content to be used just for a limited program or wheteher it can be called from many independent programs. For the first purpose it is better to implement a form whereas for the second we implement an FM.

However, ABAP does not isolate the usage context. That is; you can call a form from another program within whose code the form is not actually implemented. However, this requires attention since the form may utilize global variables.

The same issue holds for FMs. FMs are encapsulated in function groups and function groups may have global variables that can be globally used by all FMs inside it.

Subroutines are loacl to a progarm.. It cant be extended to other program.

But Function Modules are similar to subroutines but are global in view and can be used in many program.

Subroutine have three types.

pass by value, pass by reference and pass by value and reference similar to pointers but not exactly the same.

Function modules are used in BDC , BAPI etc..

Also there are standard FMs which can be used.

Reward if useful!

Read only

rodrigo_paisante3
Active Contributor
0 Likes
646

Hi,

Maybe these links help you