‎2006 Jun 14 7:48 PM
Can onyone explain me or give me some links regarding Function Module. I am confused on why exaclty does the exceptions tab is for.
Sehjal.
‎2006 Jun 14 8:03 PM
A function module is nothing but a reusable piece of code that can be called from within your code. It takes in some inputs and returns some outputs and probably changes somethings as well. But you want to know when something goes wrong in the code. How will the function module relay that to you? It can send that information as a return parameter(BAPIs and some function modules are examples of this) or it can raise the exceptions that you can trap and do something based on the exception raised. Exceptions are nothing but something unexpected that happened in the function module that is considered as unsuccessful execution of the function module. These exceptions are returned in the form of their integer values. So when you call the function module, you will assign a number to each exception. If that exception is raised in the execution of the function module, then you get a SY-SUBRC value equal to what you set it for. You can then react to it knowing which exception was raised.
Hope this helps.
‎2006 Jun 14 7:51 PM
Hello shejal,
Basically if you are developing a custom fm or a standard fm, you can raise exceptions in the code for some error.
And you have to define those exceptions in the exceptions tab of the fm.
When you execute the fm, it will return that exception and based on that exception, it is up to you to decide what to do.
Hope this helps. If it is not clear, let me know. I will try to paste some documentation.
Thanks,
Message was edited by: Naren Somen
‎2006 Jun 14 8:03 PM
Thanks Naren,
It kinds of help me in brief but if have some documentation i think it be lot more useful for me.
Shejal.
‎2006 Jun 14 7:54 PM
Hello Shejal,
Please check this online document.
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf
Hope this will help.
Regards,
Ferry Lianto
Please reward points if helpful as a way to say thanks.
‎2006 Jun 14 8:01 PM
Hi Shejal,
The Exception tab is normally used to return the different possible errors that may occur during the data processing with the fucntion.
Eg. suppose in the function module you are selecting data and performing a mathematical calculation.
in the Exception tab define 2 exceptions :
NO_DATA
DIVIDE_BY_ZERO
select .... from .... into... where...
if sy-subrc ne 0.
RAISE NO_DATA
endif.
if b ne 0.
c = a / b.
else.
RAISE DIVIDE_BY_ZERO.
endif.
in this case if the 1st exception is encountered the function will return a sy-subrc value of 1 and if the 2nd exception happend the Function will return a sy-subrc of 2.
Hope this helps
thanks,
Puneet
based on the sequence number of no_data in the exception tab, the function module will return corresponding subrc
‎2006 Jun 14 8:05 PM
hi Shejal,
<b>Function Module</b>
Function modules are special external
subroutines stored in a central library.
SAP has provided a good number of pre
defined function modules and also we can
create our own function modules.
We can call any of these function
modules from ABAP/4 programs.
FMs are stored in central library and Subroutines are confined to a particular program.
FMs return values while Subroutines cant return.
FMs can raise and handle exceptions while Subroutines cant.
There is a difference in passing parameters to the function modules.
Declaring data as common parts is not possible for function modules.
The calling program and the called function module have different work areas in ABAP/4 dictionary tables.
<b>Table Parameters</b>
FMs can import internal tables and work areas from the main program and the changes are reflected back. This is also done through Call by Reference procedure.
<b>Exceptions</b>
FMs can raise and handle exceptions. Exceptions are such situations where error cant be dealt by the program logic, say like trying to access network resources when the network is not there.
Regards,
Santosh
‎2006 Jun 14 8:08 PM
I think i got it thanks all for the links and brief explanantion.
Shejal.
‎2006 Jun 14 8:03 PM
A function module is nothing but a reusable piece of code that can be called from within your code. It takes in some inputs and returns some outputs and probably changes somethings as well. But you want to know when something goes wrong in the code. How will the function module relay that to you? It can send that information as a return parameter(BAPIs and some function modules are examples of this) or it can raise the exceptions that you can trap and do something based on the exception raised. Exceptions are nothing but something unexpected that happened in the function module that is considered as unsuccessful execution of the function module. These exceptions are returned in the form of their integer values. So when you call the function module, you will assign a number to each exception. If that exception is raised in the execution of the function module, then you get a SY-SUBRC value equal to what you set it for. You can then react to it knowing which exception was raised.
Hope this helps.