Hello all,

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 –

  1. Create a global class in SE24
  2. Create a method in it and an event
  3. Raise the event at a particular condition in our method
  4. Create a report in SE38
  5. Create a local class and a method to handle the global event

Step1.png

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.

Step2.PNG

Step 3.PNG

In this method we will raise the event .

step_new.PNG

In the ‘EVENTS’ tab we will declare our event which will be triggered in our method.

Step4.PNG

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.

Step5.PNG

Step6.PNG

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.

Output

When the input value is in range

Step7.PNG

When the input value is out of range

Step8.PNG

If you have seen my previous documents, you will find it very easy to understand the working and handling of events in OOPS.

Happy Learning..!!!

To report this post you need to login first.

7 Comments

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

    1. Ashish Gupta Post author

      The difference I will say is that the event is created in global class while in part 2 it was all local.

      This is to show that how the events are created globally like they are given in standard classes and how we can handle it.

      (0) 
      1. Ashish Gupta Post author

        Confused by the whole series.. , I just wrote all that to target those who are new to ABAP.

        I agree that these are very basic things But it is also not necessary that everyone should know all.

        While I was new in this field, I felt bit difficult to understand those concepts. That’s why I wrote this series so that those who feel difficulty like I did can understand these concepts in the most easiest way.

        But if u feel that it’s not up to the mark then I am not having any problem. I will scrap it down.

        (0) 
        1. Suhas Saha

          Although we appreciate your idea to educate the beginners about basic topics, unfortunately SDN is not a tutorials forum!

          While you’re at the OO-event handling topic, a better post would have been for e.g., “How to handle exceptions in event handlers?”

          Tbh, I don’t see the point of segregating the event handling via local & global classes. What is the difference between the two? Have you somewhere highlighted it?

          (0) 
          1. Ashish Gupta Post author

            Thank you for appreciation sir.

            You are right, i missed that difference regarding  local & global class. I will try to make this document and my future blogs / documents better. 

            (0) 
        2. Jelena Perfiljeva

          Unfortunately, the style chosen rather encourages mindless repetition and copy-pasting than actual understanding of concepts. I hope you can see this as an opportunity for improvement. Educating others is the whole another skill set.

          (1) 

Leave a Reply