cancel
Showing results for 
Search instead for 
Did you mean: 

how to handle events in webdynpro abap

former_member188831
Contributor
0 Kudos

Hi,

can any body explain how to handle the events in webdynpro abap.

i want to know some concepts in general.

Thanks,

Accepted Solutions (1)

Accepted Solutions (1)

shwetars
Advisor
Advisor
0 Kudos

Hi Mahesh,

you can create event handlers under the actions tab in you view. evry event handler has an importing parameter wdevent of type ref to cl_wd_custom_event.

you can also create events in your component controller and they can be handled within your views

check cl_wd_custom_event class for details about what all information you get when an event occurs.

for further details you can check out the following links

http://help.sap.com/saphelp_nw04s/helpdata/en/eb/ed6f4169e25858e10000000a1550b0/frameset.htm

http://help.sap.com/saphelp_nw04s/helpdata/en/a9/c751415e3b6532e10000000a1550b0/frameset.htm

also you can try the tutorial at the following link for further clarity

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2eb11b59-0a01-0010-dfa3-8292abdf...

Regards,

Shweta

Message was edited by:

Shweta R Shanbhag

Former Member
0 Kudos

There are events associated with the various UI elements. Like lead selection for a table, click for a button etc. When you define these UI elements in your view, you need to define an action to be performed on the UI element. This will be done in the properties tab of the element. In this case, the event handler will be generated. It will have wdevent, a reference of the class cl_wd_custom_event as a parameter.

Events can also be used to trigger methods across components. You can define an event in your view or component controller, and explicitly "fire" the event. You need to write your own event handlers to handle the event.

Answers (4)

Answers (4)

former_member188831
Contributor
0 Kudos

in addition to add to my above question

if we write an event how we exactly do that?

where we write event how we handle event ?

Former Member
0 Kudos

You go to the events tab of your view. Add an event, say event1.

Then go to the methods tab, Add a method, say handle_event1. In the method type, select "Event Handler". Then in the event field of the method, press F4 and select your event name. So you have defined the method handle_event1 for the event event1. Now navigate to your method and write your code!

shwetars
Advisor
Advisor
0 Kudos

Hi Mahesh,

you can write events under the events tab in ur component controller

u can handle within your component controller or the view controller with the method type being "Event Handler".

Regards,

Shweta

PS: Award points if answer was helpfull.

former_member188831
Contributor
0 Kudos

Hi Nitya,

this is okay, i shall create an event at component controller undre event tab.

then i shall create a method with the type of eventhandler.

but give me a scenarion when and how it is useful.

thanks,

mahesh

mohammed_anzys
Contributor
0 Kudos

Hi

Component controller events will not be of much use.But methods are useful.So when you create an event , you are creating a method as well which makes it useful

Thanks

Anzy

Former Member
0 Kudos

Hi Mahesh,

events are very useful when you make use of component_usages. Consider that

the using components need to be informed when some state in the used

component is reached.

Take the ALV component as example. When the user clicks a button the

component that uses the ALV may need to perform some action on the data

displayed by the ALV component. Therefor you register for the corresponding

event.

Cheers,

Sascha

Message was edited by:

Sascha Dingeldey

former_member188831
Contributor
0 Kudos

why should i go for events and event hadler, any how i am not defining any thing in events, my code is again written in view controller method, so instead of going events why can't i use methods only (by passig parameters if reuqired like in events).

pleae let me know in detail..

Thanks,

Mahesh

Former Member
0 Kudos

Events can be especially useful in a cross component scenario where you can write handlers to events defined in other components. As Sascha already mentioned, the ALV and even OVS are good examples for this. You would handle the events defined in the OVS component in your own component. You do not need to know anything about which method to call etc. Just handle the OVS event and your search help will work.

Otherwise, within a single component, events are probably just one more way of doing things. What you achieve by a method call can also be achieved by firing events which will in turn call the event handlers.

A better way to understand will be to try and implement a similar functionality by using events, using methods etc. It will help you get a better understanding.

Regards,

Nithya

Former Member
0 Kudos

also in addition to what all the gurus have said ...difference between an eventhandler and a method is ...event handler is in response to an event like clicking of a button.

Suppose you want to search something and screen has a button SEARCH.If you don't write an eventhandler called ONACTION..for this how will you know when to call search functionality???

Of course you can write the code for search inside a method which you call inside the eventhandler....

Hope this improves your understanding

former_member188831
Contributor
0 Kudos

thanks to all the guys who contributed to me alot.

Rgds,

Mahesh.Gattu

Former Member
0 Kudos

Hi,

In general, you can keep in mind the following things.

1) An event needs to be defined in the component controller.

2) There has to be an event generation scenario which can have a fire_evt statement (eg. say inside a piece of code, you say, if the object was found, fire event display - by calling method fire_<evt_name>_evt on the controller instance)

3) Lastly, you need an event handler method which will do the corresponding processing. This can lie in the same component or a using component. The type of the method has to be specified from the drop down list and the event has to be selected using F4 Help.

This is a very general explanation. You can look into the documentation anytime for the details.

Hope this helps.

Regards,

Neha

Former Member
0 Kudos

you handle a an event by creating an event handler which will take care of the event.

Eg: if you are using a button then on click of a button you want to perform some action...you can write the code for doing so in the onaction property of the button under the eading event.Each onaction event handler has a parameter called WDEVENT which contains information about the data selected etc

Former Member
0 Kudos

Hi Mahesh,

You can refer to the following link to get more information about WebdynPro ABAP and how to develop applications.

http://help.sap.com/saphelp_nw04s/helpdata/en/77/3545415ea6f523e10000000a155106/frameset.htm

It contains a lot of tutorials too.!

Regards,

Ram