2006 May 22 12:20 PM
Please tell me how can I trigger event from ABAP program???
I have not work on this ever....Please tell me in detail......
Thanks in Advance........
2006 May 22 12:22 PM
Hi,
first, You've got to use an event handler method and thn use raise event statement wherver you want to the event to trigger.
the code is as follows.
To trigger an event, a class must
declare the event in its declaration part
Trigger the event in one of its methods
EVENTS <evt> EXPORTING... VALUE(<ei>) TYPE type [OPTIONAL].
Triggering Events
RAISE EVENT <evt> EXPORTING... <ei> = <fi>...
Declaring Event Handler Methods
METHODS <meth> FOR EVENT <evt> OF <cif> IMPORTING.. <ei>..
Registering Event Handler Methods
SET HANDLER... <hi>... [FOR]...
Handler methods are executed in the order in which they were registered
Regards,
Aswin
2006 May 22 12:21 PM
CAll the FM BP_RAISE_EVENT.
Cheers
VJ
Sorry its BP_EVENT_RAISE
http://help.sap.com/saphelp_40b/helpdata/en/fa/096f33543b11d1898e0000e8322d00/content.htm
Message was edited by: Vijayendra Rao
Message was edited by: Vijayendra Rao
2006 May 22 12:22 PM
Hi,
first, You've got to use an event handler method and thn use raise event statement wherver you want to the event to trigger.
the code is as follows.
To trigger an event, a class must
declare the event in its declaration part
Trigger the event in one of its methods
EVENTS <evt> EXPORTING... VALUE(<ei>) TYPE type [OPTIONAL].
Triggering Events
RAISE EVENT <evt> EXPORTING... <ei> = <fi>...
Declaring Event Handler Methods
METHODS <meth> FOR EVENT <evt> OF <cif> IMPORTING.. <ei>..
Registering Event Handler Methods
SET HANDLER... <hi>... [FOR]...
Handler methods are executed in the order in which they were registered
Regards,
Aswin
2006 May 22 12:23 PM
Check out the links to know more abt events.
http://help.sap.com/saphelp_erp2005/helpdata/en/9f/db9a1435c111d1829f0000e829fbfe/frameset.htm
2006 May 22 12:25 PM
In Raise Event Method should I have to create custom class and event or is there any other way???
2006 May 22 12:28 PM
And also another thing I want to ask how can I see any event triggered by any ABAP prog???
2006 May 22 12:32 PM
HI
GOOD
GO THROUGH THE FOLLOWING LINKS
http://help.sap.com/saphelp_46c/helpdata/en/fc/eb2d67358411d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2d74358411d1829f0000e829fbfe/content.htm
http://www.sapgenie.com/general/tips.htm
http://sap.ionelburlacu.ro/abap/sap2/SAP_Functions.html
THANKS
MRUTYUN
2006 May 22 12:27 PM
Hi Pousali,
You can raise events in ABAP using the RAISE EVENT statement.
The syntax is
RAISE EVENT <evt> EXPORTING... <ei> = <f i>...
Raising of events have got application in Object Oriented Programming, where you can give the coding for a Method to be executed when an event is raised.
In classes, if you want to raise events,
it should be defined as follows.
EVENTS critical_value EXPORTING
value(excess) TYPE i.
The event can be raised as follows.
RAISE EVENT critical_value
EXPORTING excess = diff.
In classes, user-defined events can be implemented by 5 steps:
1) defining the event ( as specified above )
2) defining the event handler method
eg:
METHODS handle_excess FOR EVENT critical_value OF counter IMPORTING excess.
3) Raising of the event using RAISE EVENT stmt (as specified above)
4) Provide the implementation of the method defined in step 2.
5) Register the event by using the statement SET HANDLER statement.
In the case of pre-defined events like <b>double click , right click </b> , you need to do steps 2), 4) and 5) as the event has been defined before.
Sample program can be obtained from the following link.
http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4eca79e11d1950f0000e82de14a/content.htm
Regards,
SP.
2006 May 22 12:29 PM
If you are talking about ABAP objects then
EVENTS e1 EXPORTING value(var) TYPE i.
The syntax for declaration of Event Handler Methods is as follows :
METHODS handle_e1 FOR EVENT e1 OF c1
IMPORTING var.
Set the Event Handler methods, before triggering the events, using the following statement
SET HANDLER o1->handle_e1 FOR ALL INSTANCES.
To trigger the event, use the statement RAISE EVENT.
RAISE EVENT e1 EXPORTING var = temp_var.
2006 May 22 12:30 PM
2006 May 22 12:33 PM
Hi,
to see an event triggered, just give some message in the event handler method.
and then in the debugging mode, whenever the pointer encounters the raise event statement, the event gets triggered, that is, the message inside the method gets executed.
Thanks,
Aswin
2006 May 22 1:07 PM
Hello pousali,
check this sample code for event handling:
CLASS c1 DEFINITION.
PUBLIC SECTION.
*(1)Creating event : E1
EVENTS: E1.
*(2) Creating an event handling method. This method can belong to
same or different class
METHODS: M1 FOR EVENT E1 OF c1.
Method to raise the event
METHODS : T1.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
Method : M1 will be called when the event is raised
METHOD : M1.
write:/5 ' I am the event handler method'.
ENDMETHOD.
Method : T1 will raise the event
METHOD : T1.
write:/5 'I am T1, going to raise event E1'.
raise event E1.
ENDMETHOD.
ENDCLASS.
Start-of-selection.
Data: oref type ref to c1.
Create object: oref .
Registering the event handler method
SET HANDLER oref->M1 FOR oref .
Calling the event which will raise the event.
call method oref->T1.
hope it helps,
regards,
keerthi.