03-31-2008 12:50 PM
Q]What are EXCEPTIONS?
Are they real objects in ABAP
What is its use?
04-01-2008 5:06 AM
Hi,
There are two main types of exceptions: those that can be handled and those that cannot be handled.
· Exceptions that can be handled occur in error situations in the runtime environment or in the ABAP program, where the program can continue executing after the ABAP program has handled the exception, without the system ending up in a critical state. If such an exception is not handled, a runtime error occurs.
· The second type of exceptions are those that cannot be handled. These are critical error situations in the runtime environment. Handling with ABAP means is not possible and they always cause a runtime error.
When you create an exception for a method, you can decide if you want to use the classical exceptions or the new class-based exceptions in the method. When you use the class-based method, exceptions are represented with objects of exception classes at runtime.
Prerequisites
The method for a class or interface was already created.
Procedure
To create an exception for a method:
Place the cursor on the name of the corresponding method in the method display of the Class Editor.
Choose Exceptions.
If you want to define normal exceptions for the method, enter the following:
- Exception
Specify a suitable name for the exception. You must adhere to the naming conventions for exceptions under ABAP objects.
- Description
Short description of the exception.
If you want to create a class-based exception, first activate the Exception classes checkbox and then enter the appropriate exception class(es) under Exception. Once you have pressed ENTER , the Class Builder checks if the specified exception classes really exist. If a class does not exist, you can create it at this time. Otherwise the class description is copied.
See also:
Defining Exception Classes-http://help.sap.com/saphelp_nw70/helpdata/en/92/823e6017aa11d5969b00a0c94260a5/content.htm
Implementing Methods-http://help.sap.com/saphelp_nw70/helpdata/en/18/773e18778211d1b4510000e8a52bed/content.htm
Cheers,
vasavi.v
03-31-2008 12:56 PM
Hi,
Creating Exceptions for Methods
Use
When you create an exception for a method, you can decide if you want to use the classical exceptions or the new class-based exceptions in the method. When you use the class-based method, exceptions are represented with objects of exception classes at runtime.
Prerequisites
The method for a class or interface was already created.
Procedure
To create an exception for a method:
Place the cursor on the name of the corresponding method in the method display of the Class Editor.
Choose Exceptions.
If you want to define normal exceptions for the method, enter the following:
- Exception
Specify a suitable name for the exception. You must adhere to the naming conventions for exceptions under ABAP objects.
- Description
Short description of the exception.
If you want to create a class-based exception, first activate the Exception classes checkbox and then enter the appropriate exception class(es) under Exception. Once you have pressed ENTER , the Class Builder checks if the specified exception classes really exist. If a class does not exist, you can create it at this time. Otherwise the class description is copied.
Reward points if useful....
Regards
AK
04-01-2008 4:59 AM
Hi,
Exceptions are situations that occur while an ABAP program is being executed, in which normal continuation of the program does not make any sense. Exceptions can be raised either implicitly in the ABAP runtime environment or explicitly in the ABAP program. For example, division by zero leads to an exception in the ABAP runtime environment. It is possible to determine this situation through a query in the ABAP program and to trigger an exception there.
There are two main types of exceptions: those that can be handled and those that cannot be handled.
· Exceptions that can be handled occur in error situations in the runtime environment or in the ABAP program, where the program can continue executing after the ABAP program has handled the exception, without the system ending up in a critical state. If such an exception is not handled, a runtime error occurs.
· The second type of exceptions are those that cannot be handled. These are critical error situations in the runtime environment. Handling with ABAP means is not possible and they always cause a runtime error.
As of Release 6.10, exceptions and their handling are generally based on exception classes. This concept covers the functions of the preceding concepts, enhances them, and thus replaces them.
Please go through this link.................
http://help.sap.com/saphelp_nw70/helpdata/en/02/c4e6aa19e911d5969b00a0c94260a5/content.htm
if its useful reward points
04-01-2008 5:06 AM
Hi,
There are two main types of exceptions: those that can be handled and those that cannot be handled.
· Exceptions that can be handled occur in error situations in the runtime environment or in the ABAP program, where the program can continue executing after the ABAP program has handled the exception, without the system ending up in a critical state. If such an exception is not handled, a runtime error occurs.
· The second type of exceptions are those that cannot be handled. These are critical error situations in the runtime environment. Handling with ABAP means is not possible and they always cause a runtime error.
When you create an exception for a method, you can decide if you want to use the classical exceptions or the new class-based exceptions in the method. When you use the class-based method, exceptions are represented with objects of exception classes at runtime.
Prerequisites
The method for a class or interface was already created.
Procedure
To create an exception for a method:
Place the cursor on the name of the corresponding method in the method display of the Class Editor.
Choose Exceptions.
If you want to define normal exceptions for the method, enter the following:
- Exception
Specify a suitable name for the exception. You must adhere to the naming conventions for exceptions under ABAP objects.
- Description
Short description of the exception.
If you want to create a class-based exception, first activate the Exception classes checkbox and then enter the appropriate exception class(es) under Exception. Once you have pressed ENTER , the Class Builder checks if the specified exception classes really exist. If a class does not exist, you can create it at this time. Otherwise the class description is copied.
See also:
Defining Exception Classes-http://help.sap.com/saphelp_nw70/helpdata/en/92/823e6017aa11d5969b00a0c94260a5/content.htm
Implementing Methods-http://help.sap.com/saphelp_nw70/helpdata/en/18/773e18778211d1b4510000e8a52bed/content.htm
Cheers,
vasavi.v
04-01-2008 5:30 AM
Hi,
Dealing with Exceptions
Exceptions are situations that occur while an ABAP program is being executed, in which normal continuation of the program does not make any sense. Exceptions can be raised either implicitly in the ABAP runtime environment or explicitly in the ABAP program. For example, division by zero leads to an exception in the ABAP runtime environment. It is possible to determine this situation through a query in the ABAP program and to trigger an exception there.
There are two main types of exceptions: those that can be handled and those that cannot be handled.
· Exceptions that can be handled occur in error situations in the runtime environment or in the ABAP program, where the program can continue executing after the ABAP program has handled the exception, without the system ending up in a critical state. If such an exception is not handled, a runtime error occurs.
· The second type of exceptions are those that cannot be handled. These are critical error situations in the runtime environment. Handling with ABAP means is not possible and they always cause a runtime error.
As of Release 6.10, exceptions and their handling are generally based on exception classes. This concept covers the functions of the preceding concepts, enhances them, and thus replaces them.
Creating Exceptions for Methods
Use
When you create an exception for a method, you can decide if you want to use the classical exceptions or the new class-based exceptions in the method. When you use the class-based method, exceptions are represented with objects of exception classes at runtime.
Prerequisites
The method for a class or interface was already created.
Procedure
To create an exception for a method:
Place the cursor on the name of the corresponding method in the method display of the Class Editor.
Choose Exceptions.
If you want to define normal exceptions for the method, enter the following:
- Exception
Specify a suitable name for the exception. You must adhere to the naming conventions for exceptions under ABAP objects.
- Description
Short description of the exception.
If you want to create a class-based exception, first activate the Exception classes checkbox and then enter the appropriate exception class(es) under Exception. Once you have pressed ENTER , the Class Builder checks if the specified exception classes really exist. If a class does not exist, you can create it at this time. Otherwise the class description is copied.
Syntax for TRY .. ENDTRY construct
TRY.
CALL METHOD o1->m1.
PERFORM f1.
CATCH cx_root. "Handler for all exceptions
" ABAP code(What to do when error occures)........
ENDTRY.
FORM f1 RAISING cx_my.
TRY.
IF ...... RAISE EXCEPTION TYPE cx_my2. ENDIF.
CALL METHOD o1->m3.
CATCH cx_my1 cx_my3 INTO ex.
RAISE EXCEPTION TYPE cx_my4.
CATCH cx_my4.
"Handler for exceptions of type cx_my4
" ABAP code(What to do when error occures)........
CLEANUP.
"Cleanup section, used to restore to a consistant state
" ABAP code........
ENDTRY.
ENDFORM.
Thanks®ards,
Sravani.