Exercise 3: Registering a System Event

Use

System events are passed on irrespective of the flow logic of the relevant screen.

In the previous exercise, you have registered event DLBCLICK as an application event. You now register this event as a system event.

Procedure

  1. Change the value of field wa_events-appl_event in the PBO module:

    wa_events-appl_event = SPACE.
  2. Comment out the call of method DISPATCH in the PAI module.

  3. Activate and start your program.

Check Your Work

Double-click in the text window. No text is displayed since the flow logic of the screen and the field transport are ignored.

Discussion

For system events, the PAI/PBO modules are not processed. This has the following consequences:

Advantages

  • Method DISPATCH is called automatically.

  • Events cannot be lost, since the flow logic of the screen is not processed. Field checks and any re-entries that may be required are eliminated and do not conflict with event handling.

Disadvantages

No field transport takes place when the event is triggered. This has the following consequences for accessing screen fields in event handler methods:

  • During read access, obsolete values are accessed. To be more precise: The values of the last field transport are accessed.

  • Write access to input/output fields is lost completely. During the subsequent field transport, the system overwrites input with the content of the screen field.

This means that as long as you do not access screen fields in read or write mode in an event handler method, this disadvantage has no effect.

Corrective Action

The Control Framework provides method SET_NEW_OK_CODE. With this method, you can set an application-specific OK_CODE in an event handler method. After the event handler method, the Control Framework processes the PAI event in which you can access current screen fields in read and write mode.

Modify your program as follows:

  1. In the event handler method, comment out the line event_type = text-002..

  2. In the event handler method, set application-specific OK code SHOW:

    CALL METHOD cl_gui_cfw=>set_new_ok_code exporting new_code = 'SHOW'.
  3. Read the OK code in the PAI module. To do this, add the following lines to your CASE query:

    when 'SHOW'. event_type = 'Doubleclick'(555).
  4. Activate and start your program.

The PAI event is now processed after the event handler method, and the text is displayed again.