[Web dynpro] Dictionary search help v/s OVS
Generally when we work on F4 search help for web dynpro, we end up either with an OVS or a freely programmed input help, for various reasons. The reasons being, setting of the initial search parameters, customization, a more refined hit list or mapping of the result into multiple fields. These scenarios are easily achievable by OVS through the different phases namely 0,1,2,3. But these requirements can be met by dictionary search help as well.
I personally prefer dictionary search help because of its flexibility and reusability factor.
In this blog I will describe the various steps to be followed in order to achieve an OVS like functionality through dictionary search help.
I am not explaining everything from scratch but just giving the steps to achieve the required functionality.
For this you need to create a dictionary search help exit. You can refer to the following wiki doc in case you need some info on search help exit.
1. The configuration ( Similar to OVS phase 0)
In case you want to change the title of the search help screen or the heading of the various search parameters you can make the corresponding change in the changing parameter SHLP, it contains all the customization related to the search help. A code snippet :
* Change Search help title.
shlp-intdescr-title = ‘Supplier Name’.
* Change Heading for Country.
READ TABLE shlp-fielddescr
WITH KEY fieldname = ‘LANDX’.
IF sy-subrc = 0.
<fs_fielddescr>-reptext = ‘Country’.
<fs_fielddescr>-scrtext_s = ‘Country’.
<fs_fielddescr>-scrtext_m = ‘Country’.
<fs_fielddescr>-scrtext_l = ‘Country’.
Here, I have changed the search help title and the heading of one of the parameter.
2. Initialization of search parameters ( Similar to OVS phase 1)
For this, you need to modify again the changing parameter SHLP-SELOPT.
It contains the search help parameters as select options.
In order to get the web dynpro values to be set as default values, you can use the class attribute cl_wdr_value_help_handler=>m_context_element
It contains the current web dynpro element from which the F4 has been called. And you need to do this piece of code in the call control step ‘PRESEL1’
* Get the context element from which the F4 has been called.
lo_el_supp_table = cl_wdr_value_help_handler=>m_context_element.
* get all declared attributes
static_attributes = ls_supp_table ).
IF ls_supp_table-supplier IS NOT INITIAL.
READ TABLE shlp-selopt
TRANSPORTING NO FIELDS
WITH KEY shlpfield = ‘NAME1’.
IF sy-subrc <> 0.
* Add selection criteria in case not added earlier.
ls_sel_criteria-sign = ‘I’.
TRANSLATE ls_supp_table-supplier TO UPPER CASE.
ls_sel_criteria-low = ls_supp_table-supplier.
ls_sel_criteria-shlpfield = ‘NAME1’.
IF ls_supp_table-supplier CA ‘*’.
ls_sel_criteria-option = ‘CP’.
ls_sel_criteria-option = ‘EQ’.
APPEND ls_sel_criteria TO shlp-selopt.
3. Result set ( Similar to OVS phase 2)
You can get the result set on the basis of your search parameters, which you can assign to the changing parameter RECORD_TAB.
You will write you code in the call control step ‘SELECT’
4. Mapping of the result ( Similar to OVS phase 3)
Usually in Web dynpro, we use structures for node creation, you can map your search help exporting parameters to the fields of the structure like the following in SE11. Due to this, as soon as the user makes the selection using search help, the other mapped fields will get populated automatically.
Here, I have assigned a search help for the field Supplier, and mapped Supplier ID as well to the export parameters of the search help.
Final Outcome :
Search help showing the customization and the initial search parameter value.