‎2007 Oct 03 7:13 AM
hi experts,
i am not clear with functionmodules and subroutiens
1)what is the diff b/n FM and external subroutine
2)pls explain in detail abt IMPORT, EXPORT,TABLES, AND CHANGING IN FMS
3)is it possble to upload logos to reports
thanks and regards
suresh
‎2007 Oct 03 7:24 AM
Hi,
<b>Function Module:</b>These are for Global modularizaiton. Name of a FM is unique within SAP.
Can be independently tested
Can be Remote enabled.
Can have exceptions
<b>Subroutine:</b>
These are for Local modularizaiton. Name of a subroutine is unique within a PROGRAM.
Cannot be independently tested
Cannot be remote enabled
Cannot have exceptions.
‎2007 Oct 03 7:19 AM
main diff in function modules & subroutines as folllows
subroutines for readability , modularization
fms for reusability & encapusalation
u can call fm remotly u can raise exceptions
import
fm imports values from u r abap program and make necessary changes to it and export it to program
tables can be passed to fm to make neccessary changes
yes it is possible to upload logos in reports
regards
Nagesh.Paruchuri
‎2007 Oct 03 7:24 AM
Hi,
<b>Function Module:</b>These are for Global modularizaiton. Name of a FM is unique within SAP.
Can be independently tested
Can be Remote enabled.
Can have exceptions
<b>Subroutine:</b>
These are for Local modularizaiton. Name of a subroutine is unique within a PROGRAM.
Cannot be independently tested
Cannot be remote enabled
Cannot have exceptions.
‎2007 Oct 03 7:33 AM
Hi Suresh,
Function modules are for modularization purpose. You can use 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.
Reward if helpful.
Regards,
Harini.S
‎2007 Oct 03 8:28 AM
Hi Suresh,
1)<b><u>Difference between Function Modules and Ext.subroutines:</u></b>
Both are used for modularization as already mentioned.
Function modules are created in a particular function group and is globally available.
Remote Function Modules are function modules that can be called from other SAP or NON-SAP systems. BAPI's are examples of RFC-enabled function modules.
External Subroutines are subroutines that are called from another program. .
2)<b><u>Parameters in FM</u></b> : <b>)Import</b> Contains a list of the formal parameters that are used to pass data to a function module. For further information, refer to Displaying Information about Interface Parameters
<b>Export</b> Contains a list of the formal parameters that are used to receive data from a function module.
<b>Changing</b> Contains a list of the formal parameters that are used both to pass data to and receive data from a function module.
<b>
Tables</b> Specifies the tables that are to be passed to a function module. Table parameters are always passed by reference.
<b>Exceptions</b> Shows how the function module reacts to exceptions. Actually this is usually used when we want to handle some runtime error...we can catch it using these exceptions .
3) <b><u>Logo In reports</u>:</b>Yes a logo can uploaded to reports using..picture control..or even using an fm: REUSE_ALV_COMMENTARY_WRITE.
Hope this helps.
Regards,
Simy Abraham.
Message was edited by:
Simi Abraham
‎2007 Oct 03 8:55 AM
hi
good
1->difference between function module and external subroutine.
Subroutines
Subroutines are principally for local modularization, that is, they are generally called from the program in which they are defined. You can use subroutines to write functions that are used repeatedly within a program. You can define subroutines in any ABAP program.
Function Modules
Function modules are for global modularization, that is, they are always called from a different program. Function modules contain functions that are used in the same form by many different programs. They are important in the R/3 System for encapsulating processing logic and making it reusable. Function modules must be defined in a function group, and can be called from any program.
Subroutines executes faster than the fn modules because subroutines are defined within the program and they are executed after they have been called whereas the when u call a fn module, it is defined globally and it is accessed through a fn group in which they are stored. ALso the fn group should be active at the time of calling.
3-You cant upload a logo in normal report but you can do the same in ALV Report.
thanks
mrutyun^
‎2007 Oct 03 9:06 AM
‎2007 Oct 03 10:42 AM
Hi,
<b>Function Modules</b>
a..are created thru SE37 Tcode.
b. FMs have well defined interface for developing and calling them.
ie. IMPORT, EXPORT, CHANGING,TABLES, EXCEPTIONS
c. FMs are avaialble globally.
ie any program can use them.
d. FMs are called using the syntax : CALL FUNCTION
e. FMs can be update task, RFC etc.
whereas subroutines are much limited.
f. FMs can be tested thru se37
whereas for testing subroutines, we have to write some abap code.
g.Can access the global variables of a program only using its interface.
<b>Subroutines</b>
a. are created in a program thru se38.
b. they are generally not used by other programs.
(however they can be used thru some special technique)
c. subroutines are called using PERFORM
and defined using FORM keyword.
d.can directly access the global variables of a program.
<b>Use :</b>
1 If the requirement is very specific to the
program, a subroutine can be used, other wise FM.
2. If the code is to be executed MANY TIMES,
ie in a loop - 5000 - 10000 times,
it is better to use subroutine bcos
they are faster than FM.
Just remember this much only if u want some code to be written for some specific program only then use subroutines..
Write fm's only when u think it can be used in many number of applications.
For eg: date conversion..it can be written as an fm as it can be used in many applications.
Hope u understood this.
Regards,
Simy Abraham.