Skip to Content

In every major project one will find plenty of input fields the user has to fill in. SAP’s excellent solution in the form of search help assists the user in selecting one value among dozens. Once the user selects the value he was looking for, the system puts in the code of the value but not the description. This leaves the user staring at “MO” instead of “MACAU”. By designing the system in this way, SAP’s rationale aimed at the system rather than the user, because once you want to save the information back to R3, the system immediately transfers “MO”.

Every SAP programmer devises his own strategy to overcome this obstacle. Some add a text field, showing the code’s description, next to the original input field and then add an event handler to trigger another method that fetches the description. Some will completely ignore the problem and leave the code as it is. What I want to suggest is to preserve the original SAP mechanism and icon but instead of inserting the code into this input field, I want to do two things: first insert the description rather than the code into the input field and then keep the code in memory behind the scene waiting to saved back to R3.                                             

I am not sure how many of you have heard about Freely Programmed Search Help in Abap Web Dynpro, I know I have’nt until I needed a more flexible solution to the ubiquitous problem of search help showing codes instead of descriptions. Googling a little I found these SAP’s definition and  Gokul Narasimhalu ‘s excellent article.

Well, this is it:


namely the ability to insert the description into our input field while keeping the code hidden.

A. The Search Help Project

To demo this approach I chose to use a very simple table showing a list of countries and their codes. In my context I put one node of cardinality 0:n containing two attributes namely code (LAND1) and description (LANDX).


The node is bound to a table UI element, so that when the user picks a country, I use the table ‘onSelect’ action to fire an event and close the window.

B. The Parent Project

1. In your main project add reference to our Search Help Project


2. To the component controller add a reference to the used component


3. After inserting these references your component controller’s properties tab should look like this:


4. Into your component controller context drag and drop the ‘countries’ node imported from the search help interface:


5. To your component controller add the following event handler ‘On_Search_Help’ responding to the raised event  
     ‘VH_DATA_SELECTED’.  This code simply copies the chosen line to a new node ‘Country’ of cardinality 1:1
     that will be shown in the view. Node however the simple trick used here: the values are reversed !!!!
    the description now goes into the input field while the code is retained at the context (to be shown or
     not ).

     method ON_SEARCH_HELP .

     data lo_nd_countries type ref to if_wd_context_node.
     data lo_el_countries type ref to if_wd_context_element.
data ls_countries type wd_this->element_countries.
     data lv_landx type wd_this->element_countrieslandx.
data lv_land1 type wd_this->element_countriesland1.

  data lo_nd_country type ref to if_wd_context_node.
data lo_el_country type ref to if_wd_context_element.
data ls_country type wd_this->element_country.
= wd_context->get_child_node( name = wd_this->wdctx_countries ).
= lo_nd_countries->get_element( ).
     value = lv_landx ).

    value = lv_land1 ).

  lo_nd_country = wd_context->get_child_node( name = wd_this->wdctx_country ).
= lo_nd_country->get_element( ).

    value = lv_land1 ).

     value = lv_landx ).


6. So what the user gets after clicking the search help button is this:


7. And then


   Now you can of course throw away the second input field altogether, and use the value stored  
   in the context to be saved back to R3.

   That’s it.

    Yuval Peery



To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply