Thursday 26 June 2014

OOABAP Events



Step1. Go to Tx- SE24 and create a Class.














Step2. Provide the details and Save.




















Step3. Provide a method name and click on Parameters name.









Step4. Provide an importing parameter and click on the Methods tab.










Step5. Activate the class and  click on Events tab.









Step6. Provide a Event name and other details. Click on Parameters tab.
Step7. Provide the Parameters name for the Events. Events only have exporting parameters.











Step8. Go to the Methods tab. Select the method and click on the Code button or Double click on the method name to provide the code.









Step9. Provide the below code and activate the method.  here the method raises the Event depending on some condition. Then Go Back.












Step10. Go too Tx- SE24 and define another class.













Step11. Provide the details and click on the Save button.


















Step12. Under the methods atb, provide a method name and click on the Details tab.











Step13. Here Select  the Event handle for the class and the event. This method 'HANDLE_PEAK_SPEED' is the registered event for the event 'PEAK_SPEED_REACHED' of the class 'ZCL_FOR_RAISE_EVENT'.




















Step14. After this the method is marked as Event Handler method. Now Select the method and click on the Parameters tab.











Step15. Here we can maintain the parameter name as importing parameters that are defined as exporting parameters in the event. So when the event is raised it exports the exporting parameters and those are available as importing parameters to the method.











Step16. Double clcik on the method or on the code button to define the method.









Step17. Provide the below code in the method and go back. Activate the class.











Step18. Go to Tx- SE38 and create a report. Instantiate the two class.














Step19. Run the program. The event is triggered only when the entered speed is more than 80.











Step20. This time the event is not triggered.












Step21. Again run the program & provide a speed more than 80.












Step22. The event is triggered and the event handler method is called and executed. So hence we teh the below output.











------------------------------------------------------xxxxxx-------------------------------------------------------------------

No comments:

Comments system

Disqus Shortname