01-17-2007 9:39 AM
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
01-17-2007 1:07 PM
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?
01-17-2007 9:45 AM
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
01-17-2007 9:46 AM
Hello Stefan
Made a mistake. It should be:
SET HANDLER lcl_event_handler=>handle_event FOR EVENT event OF abc.
Regards
Uwe
01-17-2007 11:11 AM
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
01-17-2007 12:46 PM
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
01-17-2007 1:07 PM
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?
01-17-2007 1:21 PM
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
01-17-2007 8:25 PM
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