Part 7: basic (but tricky) HCM Process and Forms scenario (Popup Search Helps) – Continued
This document is a continuation of document: “Part 7: basic (but tricky) HCM Process and Forms scenario (Popup Search Helps)” located at:
http://scn.sap.com/docs/DOC-39487
Continued:
Now define two actions (for Button OK and Button Search):
Defining these two actions will automatically define to methods for you:
The method ONACTIONONSEARCH is called when the user selects the search button. Put the following code into this method:
data lo_el_context type ref to if_wd_context_element.
data ls_context type wd_this->element_context.
lo_el_context = wd_context->get_element( ).
data lv_land1 type wd_this->element_context–land1.
lo_el_context->get_attribute(
exporting
name = `LAND1`
importing
value = lv_land1 ).
if lv_land1 is initial.
lv_land1 = ‘US’.
endif.
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 ).
select land1 bland bezei from t005u into corresponding fields of
table lt_t005u where spras = ‘EN’ and land1 = lv_land1.
lo_nd_t005u->bind_table( new_items = lt_t005u set_initial_elements = abap_true ).
The method ONACTIONOK is called when the user selects the OK button after making their selection. Put the following code into this method:
data lo_nd_t005u type ref to if_wd_context_node.
data lo_el_t005u type ref to if_wd_context_element.
data ls_t005u type wd_this->element_t005u.
data lv_bland type wd_this->element_t005u–bland.
data lv_bezei type wd_this->element_t005u–bezei.
* navigate from <CONTEXT> to <T001P> via lead selection
lo_nd_t005u = wd_context->get_child_node( name = wd_this->wdctx_t005u ).
* get element via lead selection
lo_el_t005u = lo_nd_t005u->get_element( ).
if lo_el_t005u is initial.
exit.
endif.
* get single attribute
lo_el_t005u->get_attribute(
exporting
name = `BLAND`
importing
value = lv_bland ).
* get single attribute
lo_el_t005u->get_attribute(
exporting
name = `BEZEI`
importing
value = lv_bezei ).
*******************************************************************************************
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_set_1 type qisrdfieldvalue.
data: l_value_set_2 type qisrdfieldvalue.
data: l_qisrsspecial_param type qisrsspecial_param.
read table lt_value_help_data with key fieldname = ‘SEARCH_VALUE_SET_1’ into l_qisrsspecial_param.
if sy–subrc eq 0.
l_value_set_1 = l_qisrsspecial_param–fieldvalue.
else.
clear l_value_set_1.
endif.
read table lt_value_help_data with key fieldname = ‘SEARCH_VALUE_SET_2’ into l_qisrsspecial_param.
if sy–subrc eq 0.
l_value_set_2 = l_qisrsspecial_param–fieldvalue.
else.
clear l_value_set_2.
endif.
*******************************************************************************************
data node_value_help_data type ref to if_wd_context_node.
data value_help_datas type wd_this->elements_value_help_data.
data value_help_data type wd_this->element_value_help_data..
if not ( l_value_set_1 is initial ).
* Send selected State Code back to form fields
value_help_data–fieldname = l_value_set_1.
value_help_data–fieldindex = 1.
value_help_data–fieldvalue = lv_bland.
append value_help_data to value_help_datas.
endif.
if not ( l_value_set_2 is initial ).
* Send selected State Text back to form fields
value_help_data–fieldname = l_value_set_2.
value_help_data–fieldindex = 1.
value_help_data–fieldvalue = lv_bezei.
append value_help_data to value_help_datas.
endif.
* Fill the context
node_value_help_data = wd_context->get_child_node( name = wd_this->wdctx_value_help_data ).
node_value_help_data->bind_table( value_help_datas ).
All that remains to be completed is the user interface of your search help. Go to the layout tab and create the following:
At this point, your web DynPro is ready to be plugged into a form. Note: this may seem like a lot of work to complete so far. However, you need to remember that you can easily add more windows and views to this existing DynPro and add more search helps easily. Most (if not all) of the code is now reusable with other search helps.
On an Adobe Form, we need to add script like the following (details given below):
Button Event: mouseDown – (FormCalc, client)
$record.CONTROL_PARAM.ISR_EVENT = “USER_EVENT_POPUP”
$record.HRASR_FORM_WINDOW.DATA[*].FIELD.value = “ ZHRASR_MY_SEARCH_HELP”
Button Event: click – (JavaScript, client)
xfa.resolveNode(“SEARCH_VALUE_GET_1”).rawValue = “US”; //Pass The Country Code
xfa.resolveNode(“SEARCH_VALUE_GET_2”).rawValue = “”; //not used in this sample
xfa.resolveNode(“SEARCH_VALUE_GET_3”).rawValue = “”; //not used in this sample
xfa.resolveNode(“SEARCH_VALUE_SET_1”).rawValue = “STATE “; //Set This With Return State
xfa.resolveNode(“SEARCH_VALUE_SET_2”).rawValue = “”; //Set This With Return State Txt
xfa.resolveNode(“SEARCH_VALUE_SET_3”).rawValue = “”; //not used in this sample
xfa.resolveNode(“SEARCH_WINDOW_NAME”).rawValue = “ASR_STATE_SEARCH “; //DynPro Window Name
Step 1: Open up your form interface. We need to first add a reference to HRASR_FORM_WINDOW.
Add Import Parameter:
Now edit your form and add an “ISR On-Form Event Button” next to State field:
**Remove any script from the Enter event
Now add script to mouseDown:
Now add script to Click:
Now in the design time configuration for you process scenario, you need to now add these field elements to your configuration. Define all the following
fields as CHAR40:
SEARCH_VALUE_GET_1 Optional First Field to Get
SEARCH_VALUE_GET_2 Optional Second Field to Get
SEARCH_VALUE_GET_3 Optional Third Field to Get
SEARCH_VALUE_SET_1 First Field to Set
SEARCH_VALUE_SET_2 Second Field to Set
SEARCH_VALUE_SET_3 Third Field to Set
SEARCH_WINDOW_NAME Dynpro Window for Search
Result:
*Note: Since you have added new fields to your configuration, make sure to activate your form status so the new fields are passed to your passed interface.
Add Import Parameter:
Now, in your form Context, drag the following fields from the form interface to the form (First check to see if they are already there):
Lastly, place seven “ISR Text” Fields on your form and map (bind) each one to the orange highlighted fields above. These fields can be hidden fields. They are just place holders for your scripts behind the form. There is no need to map (bind) a field to HRASR_FORM_WINDOW. I placed these seven fields onto my form:
The binding for each is as follows:
Now is a good time to test. You can either logon to the portal and select your process or launch directly using:
http://yourserver.com/sap/bc/webdynpro/sap/asr_process_execute?sap-client=<your client #>&sap-language=EN
My Results: