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: 

Events with Class Builder

Former Member
0 Kudos

Hi Gurus,

a simple question (I hope).

Target:

raise an event from a class method

0. create a class <i>abc</i>

1. Create a method <i>raise_event</i> for class abc in Classbuilder with only one coding row (raise event <i>xyz</i>).

2. I created a event <i>xyz</i>

3. i create a method (via Class builder) in class <i>abc</i> and set the radio button is eventhandler for and choose the class abc and the event <i>xyz</i>

4. Now i call the method <i>raise_event</i> from a report - the raise will be executed, but the method for the eventhandling will not start.

Can anybody help me?

Thanks in advance

Stefan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Ups, i solved the problem

but now I have a new one:

I raise the event from a report but it starts the handler synchron - is it possible to start the handler asynchron?

7 REPLIES 7

uwe_schieferstein
Active Contributor
0 Kudos

Hello Stefan

Sounds like that you have not <b>registered</b> the event handler method. Somewhere in your coding you should have the following statement assuming that you are using a static method:

SET HANDLER  lcl_event_handler=>handle_event_abc FOR EVENT abc OF abc.

Regards

Uwe

uwe_schieferstein
Active Contributor
0 Kudos

Hello Stefan

Made a mistake. It should be:

SET HANDLER  lcl_event_handler=>handle_event FOR EVENT event OF abc.

Regards

Uwe

Former Member
0 Kudos

Hi Uwe,

thanks for your answer - but i'm not sure were i have to paste the code snippet.

Sorry for this question

I tried it into the constructor and in the method abc - but I get this error Message.

"." or ACTIVATION... expected after "EVENT".

Can you please help?

Stefan

uwe_schieferstein
Active Contributor
0 Kudos

Hello Stefan

Let's assume your event handler method is an instance method then the coding should look like:

  DATA:
    go_myclass   TYPE REF TO zcl_abc.

* Create instance
  CREATE OBJECT go_myclass.

* Register event handler
  SET HANDLER: go_myclass->handle_event FOR EVENT abc OF zcl_abc.


* Raise the event
   go_myclass->raise_event( ).

* When the event is raise the runtime environment should go to go_myclass->handle_event

Regards

Uwe

Former Member
0 Kudos

Ups, i solved the problem

but now I have a new one:

I raise the event from a report but it starts the handler synchron - is it possible to start the handler asynchron?

0 Kudos

Hello Stefan

I am (almost) sure the event handler will always be called synchronously. Thus, the only way you could start an asynchronous task is within your (synchronously called) event handler, e.g. CALL FUNCTION '...' STARTING NEW TASK <taskname> or CALL TRANSACTION with OPTION-upmode = 'A'.

Regards

Uwe

0 Kudos

Hello Stefan,

Event Handlers get called synchronous. Beside Uwe´s suggestions there are at least 2 more options:

  • build your own stack, put the event data on it and execute it later. If you need to handle it assynchronous but simulestanely assynchronous RFC as Uwe already mentioned is the best choice.

  • another assynchronous technique is batch scheduling.


call function 'JOB_OPEN' ....
submit handler_Report    ....
call function 'JOB_CLOSE'.

Regards

Klaus