Application Development and Automation 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: 
Read only

Accessing exception information in an event handler method

Former Member
0 Likes
679

Hi,

I am trying to handle an event thrown by a fatal exception. I am able to capture the event in this event handler method. However, I need to access the PREVIOUS of the exception in this event handler method and am not sure how to do it.

Can some one please help with this?

Thanks

Saravanan.

1 ACCEPTED SOLUTION
Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
610

Hi,

Maybe you can use the object SENDER that the event export. Sender is a object reference for the previous objects.

Exemle:

methods USER_COMMAND

for event USER_COMMAND of ZCL_MAR_MVC_CONTROLLER

importing UCOMM SENDER.

Regards.

Marcelo Ramos

Hi,

I am trying to handle an event thrown by a fatal exception. I am able to capture the event in this event handler method. However, I need to access the PREVIOUS of the exception in this event handler method and am not sure how to do it.

Can some one please help with this?

Thanks

Saravanan.

3 REPLIES 3
Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
611

Hi,

Maybe you can use the object SENDER that the event export. Sender is a object reference for the previous objects.

Exemle:

methods USER_COMMAND

for event USER_COMMAND of ZCL_MAR_MVC_CONTROLLER

importing UCOMM SENDER.

Regards.

Marcelo Ramos

Read only

0 Likes
610

Hi Marcelo,

Thanks so much.

Unfortunately this event does not have any parameters defined and is not easily modifyable. Is it possible to acces the info in this case?

Thanks

Saravanan.

Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
610

Hi,

Look at this code end check if your program works in the similar way.

Here, i'm changing an atribute from one class from other class.

If it doesn't works and you can't change an atribute directelly, i really don't know other way to do this.

----


  • CLASS main DEFINITION

----


CLASS main DEFINITION.

PUBLIC SECTION.

EVENTS evt EXPORTING value(e_data) TYPE char01.

METHODS event_trigger.

METHODS set_data IMPORTING i_data TYPE char01.

PRIVATE SECTION.

DATA v_data TYPE char01 VALUE 'X'.

ENDCLASS.

----


  • CLASS main IMPLEMENTATION

----


CLASS main IMPLEMENTATION.

METHOD event_trigger.

RAISE EVENT evt EXPORTING e_data = v_data.

ENDMETHOD.

METHOD set_data.

MOVE i_data TO v_data.

WRITE: / 'New v_data value ->', v_data.

ENDMETHOD.

ENDCLASS.

----


  • CLASS second DEFINITION

----


CLASS second DEFINITION.

PUBLIC SECTION.

METHODS event_handler FOR EVENT evt OF main IMPORTING e_data sender.

ENDCLASS.

----


  • CLASS second IMPLEMENTATION

----


CLASS second IMPLEMENTATION.

METHOD event_handler.

WRITE: 'v_data value ->', e_data.

CALL METHOD sender->set_data( i_data = 'Y' ).

ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

DATA: obj_main TYPE REF TO main.

DATA: obj_second TYPE REF TO second.

CREATE OBJECT: obj_main, obj_second.

SET HANDLER obj_second->event_handler FOR obj_main.

call method obj_main->event_trigger( ).

Regards.

Marcelo Ramos