SAP Virtual/Onsite Trainings

Document Categories:

What's New?


Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 

Join the Mailing List
Enter name and email address below:
Subscribe  Unsubscribe 

Exception Classes in Object Oriented Programming

By Prasanna, Infosys


Exceptions are the errors that occurs during the execution of the program that interrupts the normal flow of control.

Types of Exceptions:


All exception classes are inherited from global class CX_ROOT and the classes that are directly inherited are



It is checked by both the compiler and runtime system. If any exception of this category found and not handled locally inside the procedure, it has been declared in the RAISING clause of the procedure’s interface



It is checked only at runtime system. when the excetions tries to leave a procedure that it has been declared in RAISING class. Generally all system exceptions like CX_SY_ZERO_DIVIDE will come under these exceptions



This type of exceptions will be choosenif the exeception can occur almost everywhere. These exceptions are always implicitly declared.

Neither the compiler nor the runtime system performs any interface checks.

Step-by-Step Approach for creation of Exception Classes

Step 1:

Go to Transaction SE24, enter class name as “ZCX_EXCEP_CLS“ .

For all exception classes “CX” will be the prefix.

Choose “Create“  button.  

Step 2:  

Popup will be displayed in the next screen. Enter the super class name “CX_STATIC_CHECK”.

Exception classes are derived from one of pre-defined basic classes CX_STATIC_CHECK, CX_DYNAMIC_CHECK or CX_NO_CHECK. So enter one of the basic classes as super classes.

Instead of creating new texts, you want can use the texts from an existing message class (which are defined in TCODE SE91). Then select the “With Message Class” checkbox.

Choose Save Button.  

Step 3:  

The initial screen of exception class will be display with some predefined attributes/Methods.

Exception classes inherit the following attributes from base class “CX_ROOT“


Step 4:

Using Tcode SE91 a message class““ is created with message 000 as shown below. Used this message class in Exception Class



Step 5:  

In Exception Class “ZCX_EXCEP_CLS”, create attributes MSGV1, MSGV2, MSGV3, and MSGV4 under attributes tab of the class builder.

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image