Skip to Content

Reusable WDA Components – Search Personalization


In my recent assignment we had to build custom WebDynpro List/Export (involving search screen and list displayed in an ALV) reports. The users of this List/Export reports can restrict the number of search results and also can personalize the number of results displayed in a single page. This personalization is user specific and should be saved from there on irrespective of the session. For this purpose we had built a reusable “Search Personalization” WebDynpro component. This blog shares the development involved in building this component. This reusable “Search Personalization component” can be used in any List based reporting. I hope this would be useful to the SDN community. Also this blog would be useful to WDA learners to understand Component Usage of WDA in depth.


A sample list export with the “Settings” button to personalize the search results is shown below. The default maximum search results option is set to 100 and the number of results per page is set to 10. If the user desires to change the default settings then he can specify his own settings and click on Apply button. The application remembers his/her settings from there on. If the user wishes to get back to the default settings, then he can click the “Default Settings” button and then click on the “Apply” button. The click of Apply/Cancel button also closes the popup window.



DB table to store user settings

Firstly we need to create a DB table which will hold the search personalization selections of different users. The below screen shot shows the DB table fields which are self explanatory. Note that this table can store the user’s personalization selections for each application and each query inside that application.

Development of Reusable component

To start with we will create a WebDynpro Interface “ZWDA_IWD_SEARCH_PERS” with context and events as shown below.

The context node “APPL” holds the name of the application which has invoked our component and the name of the search in that application.


Now, we will create the main reusable component for search personalization by the name “ZWDA_SEARCH_PERS” and implement the interface “ZWDA_IWD_SEARCH_PERS”.


Now, make the context node APPL as interface node by checking the check box “Interface Node”.  Also check the events as Interface events. Create a context node SETTINGS which holds the maximum search hits and search results per page. Refer to screen shots. 




Now, create a new view “SETTINGS” with the UI elements as shown below in the screen shot. Map the context of the component controller with the view context. Assign each of the buttons an action.

Action – ON_APPLY (Apply button)

Action – ON_CANCEL (Cancel button)

Action – ON_DEFAULT (Default Settings button)


Coding Involved

Now, let’s look at the coding involved in each of the Action methods:

The code is self explanatory. Anyways I would like to focus on the following:



wd_comp_controller->fire_get_application_evt( ). 



The above statement is used in the WDDOINT method which fires the event GET_APPLICATION. We will implement this method in the application which uses this reusable component. 



Likewise: wd_comp_controller->fire_close_popup_evt( ). 


The above statement fires the CLOSE_POPUP event on click of “Apply” button and “Cancel” button. The application which uses this reusable component opens the window and hence the window should be closed from the same application. Hence we will implement this method in the component which uses this reusable component.


Component Usage

Now, let’s use the Search Personalization component in another WDA component. Copy the standard Flight list application WDT_FLIGHT_LIST to ZWDT_FLIGHT_LIST and include ZWDA_SEARCH_PERS in Used component tab.

In the view MAINVIEW include a button “Settings”. On click of this button, open popup window (Z_POP_SETTINGS) for settings. The popup window “Z_POP_SETTINGS” will host the view “Settings”. The coding involved in this method is given below.


Create a view “Settings” and insert a View Container in it. This will host our settings screen.


Now create an Event handler method “PASS_APPL” with the event “GET_APPLICATION” (Controller: INTERFACECONTROLLER, Component Use: ZWDA_SEARCH_PERS) in this view. The coding involved in this method is given below. The basic use of this method is set the Application name and search name to the context node “APPL” of the interface controller which in turn is used by our Search Personalization component to decide which application has invoked it.

Then, create an event handler method CLOSE_POPUP with the event “CLOSE_POPUP” (Controller: INTERFACECONTROLLER, Component Use: ZWDA_SEARCH_PERS) in the component controller. This method is used to close the popup window opened. The coding involved is attached below.



Get the maximum number of search results & number of results per page by querying the DB table ZWDA_SEARCH_PRES for the logged in user and for this particular application. Then restrict the entries of internal table based on user preference and bind the table. This completes the working of the Search Personalization component. 



The reusable component we have built here is generic and can be used for any List View applications. This would be helpful if one has number of custom list view applications to be developed using WDA. Also this shows the working of component usage in WDA, which would be a great learning exercise. Hope this blog will be useful to the community.

You must be Logged on to comment or reply to a post.