How to implement Webdynpro ABAP Search help in HCM FPM Forms
SAP HCM FPM Forms
This article emphasis how to implement Webdynpro ABAP Search helps in HCM Forms.
P.Ramanan works as Technical consultant. He focuses on Webdynpro abap, ABAP, OOABAP, FPM, Portal, HCM forms, Fiori.
HCM process and forms is a subcomponent of HR Administrative Services within SAP ERP Central Component (SAP ECC). HCM Process and forms is mainly to automate the HR process. SAP has delivered PA and PD Standard forms to update respective infotypes. SAP does not support all the PD infotypes under decoupling framework. Only certain infotypes are updated through standard back-end service. For the rest of the service we have to implement Custom Generic Basic or Advanced backend service to validate and update the values. In the same way SAP has not given search helps to some PD infotype fields (ex. AUFNR – order field and WBS element).
In this document I explained in a simple way how to implement Webdynpro ABAP search help in HCM FPM forms.
Before stepping into scenario I would like to recommend the reader should possess basic knowledge on creating HCM process and forms.
I had a scenario to create a custom HCM forms to update Cost Distribution infotype 1018. SAP had not given standard search help for some fields (ex. AUFNR, WBS element).
I have created HCM process and Form scenario named ‘ZHR_COST_DISTRIBUTION ‘and assign the standard SAP_PD backend service. The requirement is to enable search help to the below highlighted POSNR (WBS element field).
To achieve the Webdynpro search help functionality we need a Webdynpro abap search component. So that I create the Webdynpro component ‘ZHR_WBS_SEARCH_HELP_COMP’.
Implement the interface ‘IWD_VALUE_HELP’.
Once the interface is implemented a method ‘SET_VALUE_HELP_LISTENER’ will be available in the component controller.
Create an attribute ‘VALUE_HELP_LISTENER’ of public type reference to ‘IF_WD_VALUE_HELP_LISTENER’. This attribute is to hold the object reference of the Listener interface. This attribute listens to the click event of HCM forms field in which we assign the search help and invokes the Webdynpro component. And once the search is done this listener object transfers the value back to the HCM form.
WD_VALUE_HELP Window will be added to the Webdynpro component as a part of implementing the interface ‘IWD_VALUE_HELP’. Create a context for search help field. In this example I created the context I1018_POSNR of type PS_PSP_PNR. In the context attribute select the input help mode as ‘Dictionary Search help’ and provide PRPM as Dictionary search help value.
Design the view layout and assign context attribute to the UI element in the screen. Keep a button in the screen. The button event is to transfer the search help value using listener object reference and to close the search window.
Add the view to the window ‘WD_VALUE_HELP’.
The Design part is completed. Next we have to write the logic in the Webdynpro component to listen to the search help event triggered from the HCM form and to transfer the search value.
Implement the below code in the interface method ‘SET_VALUE_HELP_LISTENER’ in the component controller.
wd_this->VALUE_HELP_LISTENER = LISTENER.
Write the below code in the button event and activate the Webdynpro component.
METHOD onactionok .
DATA : lo_listener TYPE REF TO if_wd_value_help_listener,
lv_name TYPE string.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_i1018_posnr TYPE wd_this->element_context–i1018_posnr.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
* get single attribute
name = `I1018_POSNR`
value = lv_i1018_posnr ).
* Getting the object reference of interface for search help
lo_listener = wd_comp_controller->value_help_listener.
* Gives the name of the attribute from where F4 help is triggered
lv_name = lo_listener->f4_attribute_info–name.
get_node( )->get_node_info( )->
get_controller( )->get_context( )
element = wd_comp_controller->
new_value = lv_i1018_posnr ).
* Set the selected value in the attribute
lo_listener->f4_context_element->set_attribute( name = lv_name
value = lv_i1018_posnr ).
* Instruct to close the Pop up window
Webdynpro Component Design and coding part is completed. Now this search help component has to be plugged in to the HCM forms.
In the HCM form under form scenario in fields select the input help against the field. In this example I select the field I1018_POSNR.
Check the active check box against Webdynpro input help and pass the Webdynpro component name in the Data binding service. And select the Tick button to close the window.
Save the HCM forms and run. WBS field is enabled with search help.
Click on Search option opens the below screen.
Click on Start Search and select the value.
Click on Accept button to transfer the value to the HCM form.
Finally selected value is transferred to HCM form Context.