Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

function module exception

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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

gopi_narendra
Active Contributor
0 Kudos

exceptions are being returned by sy-subrc for any function module.

Former Member
0 Kudos

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

Former Member
0 Kudos

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