Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Raise event..........Help me out

Former Member
0 Kudos
1,376

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........

1 ACCEPTED SOLUTION

Former Member
0 Kudos
412

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

11 REPLIES 11

Former Member
0 Kudos
412

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

Former Member
0 Kudos
413

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

0 Kudos
412

0 Kudos
412

In Raise Event Method should I have to create custom class and event or is there any other way???

0 Kudos
412

And also another thing I want to ask how can I see any event triggered by any ABAP prog???

Former Member
0 Kudos
412

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.

rahulkavuri
Active Contributor
0 Kudos
412

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.

former_member188685
Active Contributor
0 Kudos
412

Hi,

you can try with <b>SWE_EVENT_CREATE</b>, to create the workflow.

check this..

Regards

vijay

Former Member
0 Kudos
412

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

Former Member
0 Kudos
412

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.