Processing Office Application Events 
Purpose
You can interpret events triggered by the office application or users of the office application in your ABAP program and react to them. The following events exist:
Process flow
1. Register the events that you want to interpret in your program. You do this in the method call for
init_control on the instance control.-
Static methodsSET HANDLER c_event_handler=>close_event FOR document.
SET HANDLER c_event_handler=>custom_event FOR document.
-
Object methodsDATA o_event_handler TYPE REF TO class_event_handler.
CREATE OBJECT o_event_handler.
SET HANDLER o_event_handler->close_event FOR document.
SET HANDLER o_event_handler->custom_event FOR document.
CALL METHOD cl_gui_cfw=>dispatch
IMPORTING return_code = return_code.