09-20-2006 9:11 AM
Experts
why we are going for exception in function module,
are these exception get catched as in java . are
this exception will not stop normal processing
of program , in case it got triggered.how we know
what exception to define for a function module
09-20-2006 9:13 AM
in case of Exceptions in FM it will return thru SUBRC , Most of the time we will use BAPIs in case of Interfaces.
Regards
Prabhu
09-20-2006 9:13 AM
exceptions are being returned by sy-subrc for any function module.
09-20-2006 9:18 AM
Hi,
Function modules are independent piece of code, which can be executed independently. we need to pass the parameters to it and get the result out of it. while processing the code, it may throw an error at several places. in case of such errors program should come to the place where function module is called. hence there is a provision of exceptions. this will not stop the program execution inside the function module. it only raise the exception.
in main program you can read the number of that exception and raise appropriate message for it.
Regards,
Rahul
09-20-2006 9:40 AM
Hello,
Exception handling is very imprtant while creating FM's.
Suppose assume that you are calling a FM and in that function module you have written query to select some entries from the table and you are returning the table. Assume that the internal table returns NULL table. ( Bacause select query is not met).
In the calling program you are using this returned table from the FM in another query in the context FOR ALL ENTRIES.
According to the rule the internal table should not be used in the context FOR ALL ENTRIES is the table is empty.
So this just define a exception called NO_DATA in the FM and after using the select query in the FM, check for sy-subrc value. if it is 0, then export the table else, raise exception using RAISE NO_DATA.
So now in the calling program you can decide to go further to use that retunred table ffrom the FM using the sy-subrc in the FM exceptions.
This is only a instance. There are amyn examples like this top explain. Yes as you said it's similar to raising to exceptions in JAVA.
I hope this is clear.
Regs,
Venkat Ramanan N