Skip to Content

EVENTS!!!!! A very strong concept but not as widely used as it should have been. Generally we tend to do our programming in the conventional way which can be done in a much simpler manner using events. There are many ways to share data between components using interface nodes, interface methods, interface events from which events many times is the best approach.

Concept of Event

Event is created which can be fired on any action. This event can be used to share data across component.

Creating an event

Events can only be created in the Component Controller.

Note The event needs to be an interface event if you need to share something anywhere outside that component..

Event have exporting parameters where we can pass any variables or any object references.

file2.JPG

file3.JPG

Creating event handler method

Create a new method in the method tab and specify the type as Event Handler. The Event and the controller tab will become enabled. Press f4 on Event column. The event that was created in component controller will be seen. Select the event.

file1.JPG

Raising an event

Whenever we create an event a method is created in the component controller class with name fire_<event name>_evt( ). So if we want to raise the event on click of some button we just have to call the method of component controller. So in view controller method we have to call wd_comp_controller->fire_call_activity_evt( ) where call_activity is the name of my event.

Passing and receiving the data through events.

Data passed In the event are shown with the same name in signature in event handler method.

file4.JPG

The following graphic shows an example in which a method of the component controller triggers the event MY_EVENT.

/wp-content/uploads/2013/06/h_00100050000_image004_226990.gif

The event handler MY_HANDLER of a view controller responds to the event MY_EVENT, because this event of the component controller is assigned to this event handler. It has been assigned on the Methods tab of the view controller.

Situations where events are helpful

  1. When Opening a pop up window as a search help on a button, the data is selected and the SELECT button is pressed. Selected data should be visible in the input field.

file5.JPG

Screen shot shows the pop up which was opened on pressing the Search button of KPI. We select the value and press SELECT button in the pop up.

Step 1 : Pop Up component is set as component usage in the Main component.

Step 2 : Pop Up is created on press of the Search button.

Step 3 : Create the event select_kpi in Pop up component and set the exporting parameter as lo_kpi.

Step 4 : Select any entry in the pop up and press SELECT button. The event wd_comp_controller->fire_select_kpi_evt( lo_kpi ) is called.

Step 5 : The event handler for this event is created in the main component. As soon as the event is fired the event handler is called where we can catch the passed value and bind the Input field.

2. On selection of some criterion on Screen 1 of component 1 something needs to be changed on screen of component 2. For example there are two radio      button on screen of component 1 and based on the selected radio button different set of fields needs to be shown on screen of component 2.

Step 1 : Create radio button group in component 1.

Step 2 : Create a text view which will be set dynamically on select of Radio button in another component.

Step 3 : Use Component 1 as used component in Component 2. Embed the radio button view in the MAIN view of second component.

Step 4 : Create a event in Component 1 select_radio_btn which will pass the text of the selected radio button.

Step 5 : On select of the Radio button fire event wd_comp_controller->fire_ select_radio_btn _evt(  lw_text ).

Step 6 : Create the event handler in Component 2 where the passed value will be recorded and set to the dynamic text.

file6.JPG

file7.JPG

3. OVS use the event handling to send the instance of the OVS component through which the methods of the OVS components are called.

4. ALV component use the event handling to send back entered data.

So start thinking now where you can avoid interface nodes and interface methods and can replace them by interface events.



To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply