‎2006 May 30 7:54 AM
Hi
I have an internal table containing Key and Value as fieldnames. I have defined follwoing methods.
ADD(KEY, VALUE);
VALUE GET(KEY);
SET (KEY, VALUE);
DELETE(KEY);
In the Get Method, i need to pass a key, it must return the value. If the key is not found, it must raise some user defined exception. Similar case with set and delete also.
Can anyone tell me in detail how to implement exceptions in my case?
‎2006 May 30 8:05 AM
Hi,
first define the exception in the exception column of the method.
whenever u want to raise the exception.
<b>syntax
raise exception_name.</b>
that`s all you have to do.
u have manually raise exception in if condition as per the logic.
These exceptions are called checked exceptions because whenever u called method using pattern these exceptions are shown in the exception.
Mark Helpfull answers
Regards
‎2006 May 30 8:20 AM
hi Manoj,
Can you able to expalin me how to define exceptions
Regards
Sreekar M
‎2006 May 30 8:25 AM
Sreekar,
When you are creating a method, you will write the name of the method and now click on the EXCEPTIONS button. Here you can list all the exceptions you want for that method.
Inside the code for the method, you will have to use the
RAISE EXCEPTION_NAME.
That is all. Now this exception will have to be handled by the code which calls this method.
Regards
Ravi
Note :Please mark all the helpful answers
‎2006 May 30 9:39 AM
Hi RaviKumar,
if suppose I have a class A in which i have a method GET which has key as datamember. It also have ref to class B as datamember.
I have another class B in which all the methods in my prev post are mentioned.
GET in the Class A contains
BREF - > GET(KEY).
So how to handle the exception.
CLass B MEthod will look like this:
VALUE GET(KEY,VALUE)
{
READ TABLE....
IF SY-SUBRC NE 0
RAISE VALUE_NOT_FOUND(defined in exceptions).
.....
}
‎2006 May 30 8:14 AM
HI
GOOD
In exception reporting you select and highlight objects that are in some way different or critical. Results that fall outside a set of predetermined threshold values (exceptions) are highlighted in color. This enables you to identify immediately any results that deviate from the expected results.
Exception reporting allows you to determine the objects that are critical for a query in you Web application.
You can find additional information under Exception Reporting.
Prerequisites
You have called up the exceptions function to change or define a condition.
· In the Web item List of Exceptions.
· In the Web item Ad-hoc Query Designer
· In the Standard Web Template for Ad-hoc Analysis or in the BEx Web Analyzer
GO THROUGH THIS LINK
http://help.sap.com/saphelp_nw04/helpdata/en/c2/f6843b49f6a40de10000000a11402f/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/cb/89fa3a0376a51fe10000000a114084/content.htm
THANKS
MRUTYUN
‎2006 May 30 8:23 AM
Hi,
that is done by using statement EVENTS in the definition of class.
Declare an event KEY_NOT_FOUND with exporting parameter of KEY, so when key is not found in the method of GET, use statement RAISE KEY_NOT_FOUND exporting 'Key number'.
Now when this event is raised in the program, you need to create an event handler which will handle this event.
‎2006 May 30 9:51 AM
Hi !
Exceptions can only be raised from function moduls.
There you can create them in the "Exceptions" register.
Simpley define and name it there.
Then you can raise it in your funcion module's code i.e.
RAISE MY_TEST_EXCEPTION
If you'd like to do so from a report... That's not possible. You can only do "Messages" from there i.e. E or A messages.
Hope that helped a bit.
Regards
Rainer
Some points would be nice...