‎2008 Jul 14 1:21 PM
Hi,
could anyone please tell me the correct statements in the below...
1)Class based exceptions can be raised using ABAP statement RAISE EXCEPTION.
2)Class based exceptions can be raised by the runtime environment.
3)Class based exceptions are limited to object oriented contexts.
4)Class based exceptions can be raised and handled in all ABAP Processing blocks.
Thanks in advance.
vijay
‎2008 Jul 14 1:37 PM
Hello,
You can get the answers to your questions in the article above:
[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f86c9290-0201-0010-7a93-dda3716dc0d2].
Regards.
‎2008 Jul 14 2:03 PM
Hi,
In your case 1 and 2 will be correct ans.
For detail clarification refer to,
[http://help.sap.com/saphelp_nw70/helpdata/en/55/bff20efe8c11d4b54a006094b9456f/content.htm]
Regards,
Anirban Bhattacharjee
‎2008 Jul 14 2:07 PM
Hi,
The use of class-based exceptions is not restricted to ABAP Objects. On the contrary, class-based exceptions are designed to replace the previous concepts. Class-based exceptions can, therefore, be raised and handled in all ABAP contexts (programs, processing blocks). In particular, all the previous catchable runtime errors can be handled as class-based exceptions.
Class-based exceptions are either raised by the ABAP statement RAISE EXCEPTION or by the ABAP runtime environment. If a class-based exception occurs, the system interrupts the normal program flow and tries to find a suitable handler. If it does not find a handler, a runtime error occurs.
Handlers are not only defined for the statements within a program but are defined for entire call sequences. Exceptions that are raised in procedures but are not handled in the procedure itself are forwarded to the caller. The caller can either handle the exception or forward it. To ensure that the caller of a procedure knows which exceptions may occur in a procedure, all the unhandled exceptions of the procedure must usually be listed in their interface after the RAISING interface parameter. This rule can be circumvented using specific exception classes.
Handlers are defined for one or more exception classes. To define handlers for all the subordinate classes of the exception classes, a superclass is specified. This enables entire groups of related exceptions to be handled.
Grouping self-defined and predefined exceptions on the basis of exception classes provides users with the option of raising all the exceptions themselves. It also offers the advantage of consistent error handling throughout the entire program flow. The ABAP syntax for class-based exceptions results in a clear distinction between normal program processing and error handling. The syntax check supports the programming of the exception handling as far as possible by identifying exceptions that have not been handled or forwarded.
Check this Link you will get the Answer.
http://help.sap.com/saphelp_nw70/helpdata/en/cf/f2bbc8142c11d3b93a0000e8353423/content.htm
http://help.sap.com/saphelp_nw70/helpdata/en/83/636d1412fc11d5991e00508b5d5211/content.htm
Regards,
Sujit
‎2008 Jul 15 10:40 AM
‎2008 Jul 18 9:14 AM
Hi Guys
this is GOBBLEDOOK -- I think the OP needs a CLEAR answer which explains what he wants.
For example I'm using the Function Module DAYS_BETWEEN_TWO_DATES for determining things like shelf life.
However the silly function module only has a NUM 6 field (with a sign) so including the sign if you say compare a date with today and say year 2500 then you'll get a CONVT_NO_NUMBER exception. Since people can quite correctly enter a date of 31.12.9999 for a shelf life expiry then if you want to see how many days before the product needs to be replaced the program will fail.
So simply do something like this. I've wrapped the function module into a class ZCL_GET_DAYS.
METHOD daycount .
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = sy-datum
i_datum_von = fromdate
i_stgmeth = '2'
IMPORTING
e_tage = daytot
EXCEPTIONS
method_not_defined = 1
OTHERS = 2.
CATCH SYSTEM-EXCEPTIONS convt_no_number = 5.
lv_days = daytot.
ENDCATCH.
IF sy-subrc = 5.
if fromdate ge sy-datum.
lv_days = 9999.
lv_days = lv_days * - 1.
ENDIF.
ENDIF.
ENDMETHOD.
now my application program won't blow up / short dump when calculating the days.
data: go_days type ref to zcl_get_days.
if go_days is initial.
create object go_days.
endif.
lv_days = go_days->daycount( p1 ).
parameter p1 is the expiry date which ccould be 9999.12.31
I think actual examples are probably more useful than "canned definitions" from the help menu or lists of loads of links.
For using your own class based exceptions you need to create a handler and code the whole lot within a TRY --ENDTRY but I can honestly say that I've never found a need for these --the system exceptions are easy to use and cover nearly every case you are likely to need in day to day abap work.
Cheers
jimbo