Hello all,

          In my other document ( Simple event handling in ABAP OOPS ) I showed how to use the standard events which are present in standard classes (for ex. cl_gui_alv_grid). Sometimes we create our programs or reports by using our own custom classes. And in those classes we may or may not define events.

For this document the scenario is like this –


-> User will enter a value

-> If the value is between 1 – 8 it will give output

-> If value is lesser then 1 or greater then 8 , it will give a message


Create a report in SE38.

Declare two classes , one class will contain the working and event , and other one will contain the method to handle the event of first class.

Input1PNG.PNG

As we can see that event is declared by declaring EVENT in a class. Our event is ‘ le_event ‘. We will try to give the message for wrong input using this event,

for that we will use RAISE EVENT statement. The method which we have declared in second will do the working whenever this event is raised.

Create the objects for the classes and we will register our method of second class as an event handler for our event.

input2.PNG


Provide the implementation for our classes.


Capture.PNG

In implementation of first class, I have given RAISE EVENT statement in if-else condition. This statement will trigger the event and to handle this, method ‘handle_le_event ‘ is used.


On execution it will work like this.

if value is between 1-8

Output1.PNG

else


Output2.PNG


For more better understanding please check the two documents which I have attached.


To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply