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

function module

Former Member
3 REPLIES 3
Read only

Former Member
0 Likes
269

Hi,

Here is the notes of differences bet. FM and Subroutines.

Hi Function modules are for modularization urpose. You can the Function Module in any program. That is available all over in the SAP system.

Where as subroutine is program specific. Once you create a subroutine in one program then you can use that in that program and related programs like includes in the program or you have to call the subroutine specifically using the main program name.

Finally subroutines are for program modularization. Not for generic use.

FM's are for generic use. Not program dependent.

FMs are mainly used when a routine is to be performed by many programs.

Subroutines (forms) are generally only executed within one program.

You can perform routines from other programs, but it's not often done.

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.

Regards,

Priyanka.

Read only

Former Member
0 Likes
269

<b>Function modules</b> are special external subroutines stored in a central library.

Can be created users own function modules.

The main difference between a function module and a normal ABAP/4 subroutine is a clearly defined interface for passing data.

The calling program and the called function module have separate work areas for ABAP/4 Dictionary tables.

Several function modules can be combined to a function group in the program library with the attribute type F with definition of global data that can be accessed from all function modules of one function group.

If an <b>internal subroutine</b> is needed, the program code of internal subroutines can be placed directly behind the ENDFUNCTION statement of a module. This subroutines can be called from all modules of the function group, but for clarity, should be called only from the function module behind which it is written.

To create internal subroutines that can be called from all modules of one function group <fgrp>, use special INCLUDE programs L<fgrp>F<xx>. You can open these INCLUDE programs easily by double clicking their names in the main program SAPL<fgrp> after selecting Main program on the Function Library->Maintain Function Modules screen.

reward points if it is usefull ....

Girish

Read only

Former Member
0 Likes
269

Hi,

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.

<b>Reward points</b>

Regards