Using ABAP Exception classes with Message classes (Part 1 of 2)

We’ve talked about Exception Classes, and we’ve talked about Message Classes. Now let’s see how we can combine these two together.

Let’s take a scenario, in which you have an exception that is thrown whenever a database error occurs in your program. Let’s call this exception class CX_DB_ERROR. We want our exception to display various messages that can also be translated later on to different languages. For example, “Error when writing to database” or “Error when reading from database”. So let’s combine ABAP Exception and Message classes.

1. First, create a message class through SE91. For this example’s sake, let’s call it CM_DATABASE_MESSAGES

2. Add a few messages to the message class. For our example, let’s add the message: “An error occurred when writing to table &1”. &1 indicates that a parameter would be inserted to the message. This parameter would be the name of the table that caused the error. We’ll get back to this in a few minutes.

3. Now open SE80 and create the exception class CX_DB_ERROR .

4. Remember that our message from step 2 states which table caused the error? Now’s the time to add this parameter. So click on the “Attributes” tab, and add an attribute for the table name. Let’s call it TABLE_NAME, and give it the type STRING.

5. Next, click on the “Texts” tab.

6. Enter a key to the message you would like to display on your exception class. In our example, let’s add the key WRITE_ERROR, indicating an error occurred when writing to the database.

7. Click on the “Message Text” button.

8. A new dialog opens, titled “Assign Attributes of an Exception Class to a Message”.

9. In the field “Message Class”, insert the name of the Message Class associated with your exception class. Let’s insert the class CM_DATABASE_MESSAGES, which we created earlier.

10. Now we need to choose the message number. Click on the choice button and choose the message “An error occurred when writing to table &1”. The number of the message should now appear in the field (as we created only one message in our example, it should be 000).

11. Now, you have to choose attributes that would be associated with the parameter &1. Click on the drop down list button, and choose the TABLE_NAME attribute we created earlier.

12. Save everything and activate.

You’ve just finished creating an exception class that uses a message class. In the next post, I’ll show you how to use the exception class with the message.

16 comments:

Anonymous,  June 6, 2011 at 3:55 PM  

Download SAP Material from

wwww.way2sap.com

Anonymous,  September 1, 2011 at 11:13 AM  

Learn SAP on your own from the following SAP Forum website

www.way2sap.com

Unknown February 25, 2013 at 1:53 AM  

Your given most of the use full information..The Sales and Distribution (SAP SD) consists of all master data, system configuration, and
transactions to complete the Order to Cash process.
It includes the following information and processes.SAP SD TRAINING IN A SIMPLE WAY.

sap sd online training

Unknown January 26, 2015 at 10:52 AM  

After reading this post I got an idea about on this note.Really something grate in this article ,Thanks for sharing this. We are providing SAP courses training online. After reading this slightly am changed my way of introduction about my training to people. To know more Visit Us SAP PM Online Training Course

Unknown May 18, 2015 at 9:18 AM  

This information which you provided is very much useful for us.It was very interesting and useful for sap online training.We also providing catminds online training institute in USA.

Unknown August 10, 2015 at 11:29 AM  

Pretty good post. I just came across your site and wanted to say that I’ve really enjoyed reading your posts. In any case I’ll be subscribing to your feed and I hope you will keep a good work!Cheer!

Regards
sap sd and crm online training
sap online tutorials
sap sd tutorial
sap sd training in ameerpet
sap crm training tutorial

peterjohn August 10, 2015 at 12:09 PM  

I appreciate you sharing this article. Really thank you! Much obliged.
This is one awesome blog article. Much thanks again.


oracle online training
sap fico online training
dotnet online training
qa-qtp-software-testing-training-tutorial

OnlineITGuru September 9, 2015 at 1:55 AM  

Oracle DBA Online Training
http://onlineitguru.com/oracle-dba-online-training-placement.html
Oracle DBA Online Training at online it guru with 9+ years of hands on expert trainer, we provide Job oriented and certification level online training with placement assistance.

Packers Movers Hyderabad October 3, 2015 at 3:55 AM  

Packers and Movers Hyderabad are blasting these days at huge scale. Resettlement is a pitiable errand for which individuals take bunches of stress. In any case, with the assistance of our organization this errand of moving can be get less demanding and smoother
http://packersmovershyderabadcity.in/
http://blog.packersmovershyderabadcity.in/

Unknown November 9, 2015 at 11:44 PM  

Thanks for nice post. I like it. We are Providing online training smartmindonlinetraining

Anonymous,  February 4, 2016 at 9:46 PM  

interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts,Thanks a million once again, Regardsoracle Goldengate training in hyderabad,

Anonymous,  February 24, 2016 at 10:40 PM  

Thanks for sharing these information. It’s a very nice topic. We are providing online training classesSAPWebDynproonlinetraining

About This Blog

This blog contains tips, tricks, tutorial, and some of my personal experiences with the SAP ABAP language.

FEEDJIT Live Traffic Feed

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP