2007 Sep 07 11:04 AM
Hi All,
Can anybody tell me about the main difference between subroutine and a function module???
Thanks in Advance!
Kiran
2007 Sep 07 11:07 AM
function modules are mainlu useful n case of global declaration. and function modules return values whee as subroutines doex not.
2007 Sep 07 11:06 AM
<b>SUBROUTINE</b>
PERFORM GET_DATA.
select * FROM ..........
ENDFORM.
<b>FM</b>
COMMIT_WORK
GUI_DOWNLOAD
GUI_UPLOAD
FM can be used in different programs.
Subroutine can be used only in a single program
2007 Sep 07 11:07 AM
function modules are mainlu useful n case of global declaration. and function modules return values whee as subroutines doex not.
2007 Sep 07 11:08 AM
Hi,
Sunroutines and function modules does the same work..
Subroutines are with in a program and Function modules are global across SAP..
you can call FM in any program but Subroutine you can call with in a program..
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.
Subroutines are defined locally in the program and FMs are globally defined in SAP system.
You cant upload data or remotely access data using Subroutines, its possible in FM
rewads if useful,
regards,
nazeer
2007 Sep 07 11:08 AM
Subroutine can be used in the same program and it is not global.
FM can be used by any number of programs and are global.
You can create your own FMs too and use existing FMs which are defined for different puposes
2007 Sep 07 11:08 AM
Hi Kiran..
Function Module:
These are for Global modularizaiton. Name of a FM is unique within SAP.
Can be independently tested
Can be Remote enabled.
Can have exceptions
Subroutine:
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.
<b>Reward if helpful</b>
2007 Sep 07 11:10 AM
Hi,
Go through the below link
http://www.sapbrainsonline.com/FAQs/TECHNICAL/SAP_ABAP_MODULARIZATION_FAQ.html
http://help.sap.com/saphelp_nw04/helpdata/en/c8/19764143b111d1896f0000e8322d00/content.htm
Reward points if u find useful.
Regards,
Nagaraj
2007 Sep 07 11:12 AM
Hi,
Subroutine <b>cannot have OPTIONAL</b> parameters.
Subroutine is <b>not a seperate reposiotry</b> object.(<b>No TADIR entry</b> for routines)
Subroutine <b>cannot be Remote</b> enabled.
Subroutine <b>cannot have Exceptions</b>
You can create as many subroutines as you want in a Function group but you can create only <b>99 Function modules.</b>
Regards,
Sesh
2007 Sep 07 11:15 AM
Hi,
Sub routine is local with in the program... Ofcourse there are ways to access subroutines from other programs...
Function Modules are global throughout the system... And one more advantage is we can make function module remote enable to access data from ohter clients/systems.
Returning values means for a subroutine or a function module u will exporting some values and based on that values the subroutine or fm will perform some logic, based on that logic the values which u have send may change so they will be returned to ur program.
for ex: to a function module u have exported a and b values and importing c in the function module
c = a + b. So here it will return the sum of a and b through c.
That is what is called as returning the values.
Regards,
Priyanka.
2007 Sep 07 11:19 AM
Hi kiran,
Differences between subroutine and FM r as follows:
<b>Function</b> : Stored in the central library and has a global presence.
<b>Subroutine</b> : It is confined to a particular program.
<b>Function</b> : It can return values.
<b>Subroutine</b> : It cannot return values.
<b>Function</b> : Can handle exceptions.
<b>Subroutine</b> : Can't handle exceptions.
<b>Function</b> : The way the parameters are passed will differ from that subroutine.
Regards...
Arun.
Reward points if useful.
2007 Sep 07 11:33 AM
Compared to Subroutines, FMs have a well defined Interface and exception handling mechanism. All the global data within a Function group can be accessed by all the FMs in that group.