‎2007 May 17 12:16 PM
1.What is a function moudule?
What is the difference between sub-routine and a function module?
‎2007 May 17 12:39 PM
hi ,
here u go with the difference :
What is the difference between the function module and a normal ABAP/4 subroutine?
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.
Apart from those:
Subroutines :
1. You must have the same number of actual parameters as formal parameters , parameters are assigned in the sequence in which they are listed.
2. When you call a subroutine using PERFORM, the system checks whether the types of the actual parameters in the PERFORM statement are compatible with the formal parameters.
3. The interface is defined in the FORM routine. USING and CHANGING in the PERFORM statement are purely documentary.
4. Internal tables are passed without their work area. You therefore need to declare one using a local DATA statement. Internal Tables must be passed by TYPE.
Function Modules :
1.Function modules are external subroutines with a transparent interface, optional parameters are allowed.
2.Are central Repository objects, and are accessible system-wide. They are present as a set of function in a function module.
3. Are developed and tested using the Function Builder
4. Can be coded to RAISE exceptions
reward if helpful !
Regards,
Ranjita
‎2007 May 17 12:17 PM
hi,
Well, they can both return values.
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
Reshma
‎2007 May 17 12:22 PM
Hi,
A function module is one of the main ABAP/4 modularization units.
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.
Leaving a function module is accomplished via the raise statement instead of check, exit, or stop.
rgds
Deepak
‎2007 May 17 12:23 PM
Hi,
Simply we can say the FM are the global subroutines stored in function library
where as subroutines are the block of individual code segments written a program
‎2007 May 17 12:39 PM
hi ,
here u go with the difference :
What is the difference between the function module and a normal ABAP/4 subroutine?
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.
Apart from those:
Subroutines :
1. You must have the same number of actual parameters as formal parameters , parameters are assigned in the sequence in which they are listed.
2. When you call a subroutine using PERFORM, the system checks whether the types of the actual parameters in the PERFORM statement are compatible with the formal parameters.
3. The interface is defined in the FORM routine. USING and CHANGING in the PERFORM statement are purely documentary.
4. Internal tables are passed without their work area. You therefore need to declare one using a local DATA statement. Internal Tables must be passed by TYPE.
Function Modules :
1.Function modules are external subroutines with a transparent interface, optional parameters are allowed.
2.Are central Repository objects, and are accessible system-wide. They are present as a set of function in a function module.
3. Are developed and tested using the Function Builder
4. Can be coded to RAISE exceptions
reward if helpful !
Regards,
Ranjita
‎2007 May 17 1:01 PM
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,
Chary.
‎2007 May 17 2:10 PM
Hi krishna
Function modules are mainly used for code reusability..instead of writing the function again n again you can very well use the already existing codes by just calling it.Function modules are available even after the control gets terminated ..
But subroutines are strictly concerned to that particular program only,if the control gets terminated then subroutines are also terminated.
REWARD IT PLEASE...!!!