Skip to Content

Sometimes you will want to provide a search help for fields of your adobe forms.  Or you may want to validate data typed into a field and maybe bring some associated text value back to the form.  Some fields that have search helps defined at the domain may automatically provide a search help for you.  In other instances, you will need to create one.  The following method of performing this functionality is considered an advanced topic and you should have a good understanding of how HCM Process and Forms works and are developed.  Note:  There are a couple of standard SAP Search Helps available for Position (HRASR_C_POSITION), Qualifications (HRASR_C_QUALIFICATION_BLK), and Org units (HRASR_C_ORGUNIT).  However, I found these limited and replaced them with my own custom search help.  I will say that there is a lot of work to be done initially setting up the popup search framework, but this only has to be done once.  Once it is done, you use the same framework for all other popups you might need.  Also, as you will see in my next example, this framework also allows you to do real time field validation without the need to do the form “Check and Send”.

In this example we will create a popup search that allows searching for a State in the USA.  Similar to this:

/wp-content/uploads/2013/03/p_197147.jpg

Here we go….

Create a Web DynPro Component:

/wp-content/uploads/2013/03/p_197147.jpg

You must implement the component interface: IF_HRASR00_FORM_WINDOW

/wp-content/uploads/2013/03/p_197147.jpg

Select the “Reimplement“ button:

We need an assistance class which inherits from: CL_WD_COMPONENT_ASSISTANCE

Create the following class: ZCL_HRASR00_WDA_ASSISTANCE

/wp-content/uploads/2013/03/p_197147.jpg

Result:

/wp-content/uploads/2013/03/p_197147.jpg

Select the superclass button and enter: CL_WD_COMPONENT_ASSISTANCE

/wp-content/uploads/2013/03/p_197147.jpg

Choose:   “Goto->Text Elements” and add the following two texts:

001         Search Window

002         Clear Selected Object

Now go back to your search help WebDynPro and enter the assistance class as follows:

/wp-content/uploads/2013/03/p_197147.jpg

Now select the component controller of your search help WebDynPro:

/wp-content/uploads/2013/03/p_197147.jpg

Go to Methods and create a method SUPPLY_TEXTS as follows:

/wp-content/uploads/2013/03/p_197147.jpg

Choose the “Context” tab:

/wp-content/uploads/2013/03/p_197147.jpg

Define the following Context Node (choosing your supply function):

/wp-content/uploads/2013/03/p_197147.jpg

Create the following two attributes under node TEXTS:

/wp-content/uploads/2013/03/p_197147.jpg

/wp-content/uploads/2013/03/p_197147.jpg

Result:

/wp-content/uploads/2013/03/p_197147.jpg

Go to Methods and modify the method SUPPLY_TEXTS as follows (insert code):

data texts type if_componentcontroller=>element_texts.
texts
title = wd_assist->if_wd_component_assistance~get_text( key = ‘001’ ).
texts
btn_clear_selection = wd_assist->if_wd_component_assistance~get_text( key = ‘002’ ).
node
->bind_structure( new_item = texts ).

Define the following Context Node (using structure QISRSSPECIAL_PARAM):

/wp-content/uploads/2013/03/p_197147.jpg

Select the “Add Attribute from Structure” button and select the following:

/wp-content/uploads/2013/03/p_197147.jpg

Result:

/wp-content/uploads/2013/03/p_197147.jpg

Choose the “Attributes” tab and define the following attribute:

Attribute:                            POPUP_WINDOW

Public:                               Checked

RefTo:                               Checked

Associated Type:               IF_WD_WINDOW

Result:

/wp-content/uploads/2013/03/p_197147.jpg

Go to Methods and modify method CALL_POPUP as follows (insert code):

  data lo_nd_special_data type ref to if_wd_context_node.
 
data lt_special_data type wd_this->elements_special_data.


  lo_nd_special_data
= wd_context->get_child_node( name = wd_this->wdctx_special_data ).
  lt_special_data[]
= special_data[].
  lo_nd_special_data
->bind_table( new_items = lt_special_data set_initial_elements = abap_true ).

  data: lr_api_componentcontroller type ref to if_wd_component,
           lr_window_manager
type ref to if_wd_window_manager.

  data lo_nd_texts type ref to if_wd_context_node.
 
data lo_el_texts type ref to if_wd_context_element.
 
data lv_title type wd_this->element_textstitle.

  lo_nd_texts = wd_context->get_child_node( name = wd_this->wdctx_texts ).
  lo_el_texts
= lo_nd_texts->get_element( ).
  lo_el_texts
->get_attribute(
   
exporting
      name
`TITLE`
   
importing
     
value = lv_title ).

  data: l_window_name type string.
 
data: l_qisrsspecial_param type qisrsspecial_param.

  read table special_data with key fieldname = ‘SEARCH_WINDOW_NAME’ into l_qisrsspecial_param.

  if sysubrc eq 0.
   
if not ( l_qisrsspecial_paramfieldvalue is initial ).
     
data lo_nd_value_help_data type ref to if_wd_context_node.
     
data lt_value_help_data type wd_this->elements_value_help_data.
     
data l_value_help_data like line of lt_value_help_data.


*    look for set variable for return 1
     
read table special_data with key fieldname = ‘SEARCH_VALUE_SET_1’ into l_value_help_data.
     
if sysubrc eq 0.
       
append l_value_help_data to lt_value_help_data.
        lo_nd_value_help_data
= wd_context->get_child_node( name = wd_this->wdctx_value_help_data ).
        lo_nd_value_help_data
->bind_table( new_items = lt_value_help_data set_initial_elements = abap_true ).
     
endif.


*    look for set variable for return 2
     
read table special_data with key fieldname = ‘SEARCH_VALUE_SET_2’ into l_value_help_data.
     
if sysubrc eq 0.
       
append l_value_help_data to lt_value_help_data.
        lo_nd_value_help_data
= wd_context->get_child_node( name = wd_this->wdctx_value_help_data ).
        lo_nd_value_help_data
->bind_table( new_items = lt_value_help_data set_initial_elements = abap_true ).
     
endif.


*    look for set variable for return 3
     
read table special_data with key fieldname = ‘SEARCH_VALUE_SET_3’ into l_value_help_data.
     
if sysubrc eq 0.
       
append l_value_help_data to lt_value_help_data.
        lo_nd_value_help_data
= wd_context->get_child_node( name = wd_this->wdctx_value_help_data ).
        lo_nd_value_help_data
->bind_table( new_items = lt_value_help_data set_initial_elements = abap_true ).
     
endif.


*    look for get variable for get 1
     
read table special_data with key fieldname = ‘SEARCH_VALUE_GET_1’ into l_value_help_data.
     
if sysubrc eq 0.
       
append l_value_help_data to lt_value_help_data.
        lo_nd_value_help_data
= wd_context->get_child_node( name = wd_this->wdctx_value_help_data ).
        lo_nd_value_help_data
->bind_table( new_items = lt_value_help_data set_initial_elements = abap_true ).
     
endif.


*    look for get variable for get 2
     
read table special_data with key fieldname = ‘SEARCH_VALUE_GET_2’ into l_value_help_data.
     
if sysubrc eq 0.
       
append l_value_help_data to lt_value_help_data.
        lo_nd_value_help_data
= wd_context->get_child_node( name = wd_this->wdctx_value_help_data ).
        lo_nd_value_help_data
->bind_table( new_items = lt_value_help_data set_initial_elements = abap_true ).

     
endif.


*    look for get variable for get 3
     
read table special_data with key fieldname = ‘SEARCH_VALUE_GET_3’ into l_value_help_data.

      if sysubrc eq 0.
       
append l_value_help_data to lt_value_help_data.
        lo_nd_value_help_data
= wd_context->get_child_node( name = wd_this->wdctx_value_help_data ).
        lo_nd_value_help_data
->bind_table( new_items = lt_value_help_data set_initial_elements = abap_true ).
     
endif.

*    create Pop up Window
      l_window_name
= l_qisrsspecial_paramfieldvalue.
      lr_api_componentcontroller
= wd_this->wd_get_api( ).
      lr_window_manager
= lr_api_componentcontroller->get_window_manager( ).

      call method lr_window_manager->create_window
       
exporting
          window_name         
= l_window_name
         
title                = lv_title
          button_kind         
= if_wd_window=>co_buttons_okcancel
          message_display_mode
= ‘0’
          close_in_any_case   
= abap_true
        receiving
         
window               = wd_this->popup_window.

      wd_this->popup_window->set_window_position( position = if_wd_window=>co_center ).
      wd_this
->popup_window->open( ).

      free lr_window_manager.
     
if sysubrc ne 0.
     
endif.

      free lr_api_componentcontroller.
     
if sysubrc ne 0.
     
endif.
   
else.
*     create a generic error popup
   
endif.
 
else.
*   create a generic error popup
 
endif.

Housekeeping is now complete.  We can start building search popups.  What we have done so far is built the interface for the web DynPro class to talk to the form and pass data back and forth.  We can start by creating a State popup search help.  First delete the view and window which were created initially:

/wp-content/uploads/2013/03/p_197147.jpg

Create a new Window and View for our state search popup as follows (you can add as many window/view combination to this same webdynpro for all your different searches.  There is no need to redo all the work which was done above for any other searches.  Yes, that’s a relief..):

/wp-content/uploads/2013/03/p_197147.jpg

/wp-content/uploads/2013/03/p_197147.jpg

/wp-content/uploads/2013/03/p_197147.jpg

/wp-content/uploads/2013/03/p_197147.jpg

Double Click your window and define the Window\View structure as follows (link the view):

/wp-content/uploads/2013/03/p_197147.jpg

Go to the View Context and define as follows:

Drag VALUE_HELP_DATA and TEXTS from the COMPONENTCONTROLLER Context to your View Context:

/wp-content/uploads/2013/03/p_197147.jpg

Also define a node that will be used for storing all the states available for selection.  Use table T005U as the structure definition since it has country, state, and text:

/wp-content/uploads/2013/03/p_197147.jpg

Select the “Add Attributes from Structure” button and select the following:

/wp-content/uploads/2013/03/p_197147.jpg

Result:

/wp-content/uploads/2013/03/p_197147.jpg

Lastly, create a context attribute for storing the country code that might be passed into the search help for narrowing down the search criteria.  Define as follows:

/wp-content/uploads/2013/03/p_197147.jpg

Result:

/wp-content/uploads/2013/03/p_197147.jpg

Go to method WDDOINIT (in your view) and insert the following code:

* Check to see if there is a defaulted country sent from the form.
* This section is generic to any type of search. SEARCH_VALUE_GET_1 will store any input
* from the form which is to be used as a default search criteria.

  data lo_nd_value_help_data type ref to if_wd_context_node.
 
data lt_value_help_data type wd_this->elements_value_help_data.

  lo_nd_value_help_data = wd_context->get_child_node( name = wd_this->wdctx_value_help_data ).
  lo_nd_value_help_data
->get_static_attributes_table( importing table = lt_value_help_data ).

  data: l_value_get_1 type qisrdfieldvalue.
 
data: l_qisrsspecial_param type qisrsspecial_param.

  read table lt_value_help_data with key fieldname = ‘SEARCH_VALUE_GET_1’ into l_qisrsspecial_param.
 
if sysubrc eq 0.
    l_value_get_1
= l_qisrsspecial_paramfieldvalue.
 
else.
   
clear l_value_get_1.
 
endif.


*******************************************************************************************


* This is the specific logic needed for retreiving values for selection.
 
data lo_nd_t005u type ref to if_wd_context_node.
 
data lt_t005u type wd_this->elements_t005u.

  lo_nd_t005u = wd_context->get_child_node( name = wd_this->wdctx_t005u ).

  if l_value_get_1 is initial.
   
select land1 bland bezei from t005u into corresponding fields of
          
table lt_t005u where spras = ‘EN’.
 
else.
   
data lo_el_context type ref to if_wd_context_element.
   
data ls_context type wd_this->element_context.
   
data lv_land1 type wd_this->element_contextland1.

    lv_land1 = l_value_get_1.
    lo_el_context
= wd_context->get_element( ).


*   set single attribute
    lo_el_context
->set_attribute(
      name
`LAND1`
     
value = lv_land1 ).

    select land1 bland bezei from t005u into corresponding fields of
          
table lt_t005u where spras = ‘EN’ and land1 = lv_land1.
 
endif.

  lo_nd_t005u->bind_table( new_items = lt_t005u set_initial_elements = abap_true ).


*******************************************************************************************


* This section is generic to any type of search.
 
data lo_api type ref to if_wd_view_controller.
 
data current_action type wdapi_action.

  lo_api = wd_this->wd_get_api( ).

* subscribe to event ok
  wd_comp_controller
->popup_window->subscribe_to_button_event(
                                     button
= if_wd_window=>co_button_ok
                                     action_name
= ‘OK’
                                     action_view
= lo_api ).

**I have maxed out the most space a document can include.  I’ll have to continue this in another document.  Not sure why we have these limits….  Arghhh…

Please see the continuing document:   

“Part 7: basic (but tricky) HCM Process and Forms scenario (Popup Search Helps) – Continued”  (http://scn.sap.com/docs/DOC-39488)

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