What if you would want to change the behaviour of the screen for instance based on an action in the screen? You might think of a scenario where you want to influence the appearance of the search view based one of the search fields.
Let’s assume you have a search view where you can specify a centain item type, which is displayed as a dropdown listbox.
You could then either create the event handler to implement your specific logic, or just use a dummy event, simply to trigger a roundtrip.
Based on the value given, you would like:
- Other search parameters to appear or disappear
- Other dropdown listboxes to change their possible values
- Inform the user with a certain message
Create an event handler for the search parameterIn the controller class of the searchquery view, method GET_DQUERY_DEFINITIONS is used to retrieve search field information. This method allows you to change the server event for search fields. Redefine this method and change the server event setting for the search parameter.
<lfs_field_info> TYPE crms_thtmlb_search_field_info.
CALL METHOD super->get_dquery_definitions
rt_result = rt_result.
READ TABLE rt_result ASSIGNING <lfs_field_info> WITH KEY field = 'ITM_TYPE'.
IF sy-subrc = 0.
<lfs_field_info>-server_event = 'ITM_TYPE_CHANGED'. "Just used for roundtrip!
Note that we are here working on the search field definition. This is not the actual raising of the event, this will be done by the framework automatically when a value is set from the dropdown.