Simple event handling in ABAP OOPS Part 3
This is the 3rd part of event handling in ABAP OOPS. In my previous documents ( Simple event handling in ABAP OOPS / Simple event handling in ABAP OOPS Part 2 ), I showed about the working of global events and local event.
In first document I showed how to handle the global events and in second documents I showed how to create a local event in a local class and how to handle it internally. So, in this document I will show how to create an event globally and how to handle it.
I know it’s a basic thing to learn but it is very important to clear the basics. And event play a very helpful role in our working.
For this document the flow will be like this –
- Create a global class in SE24
- Create a method in it and an event
- Raise the event at a particular condition in our method
- Create a report in SE38
- Create a local class and a method to handle the global event
Create a class in SE24 as shown above. Inside the class create a method INPUT_CHECK which will raise the event. We will not make it static method ( it depends on your choice ). It will take the input number and check for a particular scenario, in our case the input number should be between 1 and 7. Click on ‘Parameters’ button and give the parameters.
In this method we will raise the event .
In the ‘EVENTS’ tab we will declare our event which will be triggered in our method.
Create a report in SE38. Create a local class which will contain a method and this method will be used to handle the event of our global class.
According to the code flow of our report, we the user will pass the give the value as input.
We will pass the value to the global class method Input_Check which we have created. Internally if the value is with in range it will give output message otherwise an event will be raised and that will be handled by our local class method Handle_Event which is registered as an event handler in our code by
Set Handler Keyword.
When the input value is in range
When the input value is out of range
If you have seen my previous documents, you will find it very easy to understand the working and handling of events in OOPS.