Title.png

Applies to:

SAP HCM FPM Forms

Summary:

This article emphasis how to implement Webdynpro ABAP Search helps in HCM Forms.

Author

P.Ramanan

Created on:

16-Apr-2015

Author Bio:

Ramanan.jpg

P.Ramanan works as Technical consultant. He focuses on Webdynpro abap, ABAP, OOABAP, FPM, Portal, HCM forms, Fiori.



Introduction

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.

Scenario

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).

Untitled.png

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’.

Untitled.png

Implement the interface ‘IWD_VALUE_HELP’.

Untitled.png

Once the interface is implemented a method ‘SET_VALUE_HELP_LISTENER’ will be available in the component controller.

Untitled.png

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.

Untitled.png

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.

Untitled.png

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.

Untitled.png

Add the view to the window ‘WD_VALUE_HELP’.

Untitled.png

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.



Untitled.png


Write the below code in the button event and activate the Webdynpro component.


Untitled.png


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_contexti1018_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.
ENDIF.

* get single attribute
  lo_el_context->get_attribute(
EXPORTING
name
`I1018_POSNR`
IMPORTING
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_infoname.

  lo_listener->f4_context_element->

              get_node( )->get_node_info( )->

              get_controller( )->get_context( )

              ->add_context_attribute_change(
element
= wd_comp_controller->

                   value_help_listener->f4_context_element
attribute_name
=

                    wd_comp_controller->

                    value_help_listener->f4_attribute_infoname
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
wd_comp_controller
->value_help_listener->close_window( ).
ENDMETHOD.


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.


Untitled.png



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.


Untitled.png


Save the HCM forms and run. WBS field is enabled with search help.


Untitled.png


Untitled.png


Click on Search option opens the below screen.


Untitled.png


Click on Start Search and select the value.


Untitled.png


Click on Accept button to transfer the value to the HCM form.


Untitled.png


Finally selected value is transferred to HCM form Context.

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