‎2007 Jun 25 9:59 AM
hi
how to define our own Exceptions in th function builder in the Exception tab and how to use them in functon definiton.
regards
ravish
‎2007 Jun 25 10:02 AM
hi,
just define your exceptions in exceptions tab and call like this,
if sy-subrc eq 1.
raise ret_code." exception name
endif.
regards,
seshu.
‎2007 Jun 25 10:01 AM
‎2007 Jun 25 10:02 AM
hi,
just define your exceptions in exceptions tab and call like this,
if sy-subrc eq 1.
raise ret_code." exception name
endif.
regards,
seshu.
‎2007 Jun 25 10:03 AM
Hi,
For any function module you can in transaction SE37 you can goto Exceptions tab and there you can type your Exception names.
From then on whenever you use CALL FUNCTION you will also have to use EXCEPTIONS to list the exception that this FM might raise.
Also there is an option of creating your own Exception class example classes that start with CX___________.
You can create exception classes ans using a check box in the SE37 you can make your FM raise class based exceptions instead of normal exceptions.
Regards,
Sesh
‎2007 Jun 25 10:03 AM
Hi,
<b>Exceptions</b>
The exception of a function module are defined on the Exceptions tab page in the Function Builder. Here you can select exception classes to define whether class-based exceptions are declared or non-class-based exception are defined. Class-based exceptions are represented in the above syntax by RAISING, and non-class-based exceptions are represented by EXCEPTIONS.
The addition RAISING is used to declare class-based exceptions that can be propagated from the function module to the caller. Exceptions in the categories CX_STATIC_CHECK and CX_DYNAMIC_CHECK must be explicitly declared, otherwise a propagation can lead to an interface violation. A violation of the interface leads to the treatable exception CX_SY_NO_HANDLER. Exceptions of the category CX_NO_CHECK are implicitly always declared. The declaration of exceptions of the category CX_STATIC_CHECK is statically checked in the syntax check. For exceptions of the category CX_DYNAMIC_CHECK, the check is not performed until runtime. In a function module in which class-based exceptions are declared with the RAISING addition, the statement CATCH SYSTEM-EXCEPTIONS cannot be used. Instead, the relevant treatable exceptions should be handled in a TRY control structure.
The addition EXCEPTIONS is used to define a list of non-class-based exceptions that can be triggered in the function module using the statements RAISE or MESSAGE RAISING. Exceptions defined in this way - as with formal parameters - are bound to the function module and cannot be propagated. If an exception of this type is triggered in a function module, and no return value has been assigned to it with the homonymous addition EXCEPTIONS of the CALL FUNCTION statement when the call was made, this leads to a runtime error.
<b>Note</b>
For new developments after release 6.10, SAP recommends that you work with class-based exceptions that are independent of the function module.
Regards,
Padmam.<b></b>
‎2007 Jun 25 10:08 AM
Hi
For eg:
If you have defined exceptions in the function module
based on sy-subrc value you can raise exceptionslike
Case sy-subrc.
when 1.
rasie < exception name1>.
when 2.
rasie < exception name2>.
when 3.
rasie < exception name3>.
when 4.
rasie < exception name4>.
....
endcase.
Regards
Raj