Friday, August 5, 2022

[FIXED] How to use local exception classes?

Issue

I want to write and use a local exception class in ABAP. Keeping it easy, helps me to understand, so I simplified my case:

Lets say I have an account class with the method "withdraw". If I withdrew more than my current balance allows, an "account_overdrawn" exception class should be raised.


Solution

You must use the statement RAISE EXCEPTION TYPE (class name), assuming that the class name is in the scope in which you are doing this.

Depending on how you declared your class, you may have to pass something to its constructor. The RAISE EXCEPTION TYPE statement works just like CREATE OBJECT, but instead, you are creating an instance of an exception object.



Answered By - mydoghasworms
Answer Checked By - Timothy Miller (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.