Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
JerryWang
Advisor
Advisor

This document could be used for beginners for Webclient UI development who wants to know how to implement value help.


Example:


When clicking F4 on BusinessPartner ID,



a new window pops up as value help, you can click search button to get a list of business partners and choose one of them:



Once you mark the first search result, both ID and name would be automatically written back to your host page.



Step1: Implement GET_P method for field "BusinessPartner ID":





CASE iv_property.
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
rv_value = cl_bsp_dlc_view_descriptor=>field_type_input.
ENDCASE.

Implement GET_V method:



create object rv_valuehelp_descriptor type cl_bsp_wd_valuehelp_navdescr
exporting
iv_outbound_plug = 'OP_PARTNER_SEARCH'.

Step2: Create a new outbound plug OP_PARTNER_SEARCH: ( the name must equal to the value passed to exporting parameter in GET_V method )


define a private attribute mv_popup with TYPE REF TO if_bsp_wd_popup in your view controller.


Implement the following code:





 
DATA: lv_node  TYPE REF TO cl_bsp_wd_context_node.
DATA: lv_title TYPE string.

lv_title = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_PROD_CUST/SEARCH_CUSTOMER' ).
mv_popup = comp_controller->window_manager->create_popup(
iv_interface_view_name = 'SearchHelpWindow'
iv_usage_name = 'BPSearch'
iv_title = lv_title ).
mv_popup->set_display_mode( if_bsp_wd_popup=>c_display_mode_surrounded ).
mv_popup->set_on_close_event( iv_view = me iv_event_name = 'CLOSEPOPUP' ).
mv_popup->open( 'CLEAR_ALL' ).​




Step3: in step2 we try to open the popup window defined in component usage BPSearch, so we have to define that usage in runtime repository:


in code it is defined when value help window is closed, event CLOSEPOPUP will be triggered. So we create this event handler and implement it:


In the event handler, we get the selected BP information from context node PARTNER of component BP_HEAD_SEARCH and


set the content into our own field "BusinessPartner ID" and "Employee Name":



method EH_ONCLOSEPOPUP.

DATA: lv_target_node TYPE REF TO cl_bsp_wd_context_node.
DATA: lr_node TYPE REF TO cl_bsp_wd_context_node,
lr_entity TYPE REF TO if_bol_bo_property_access,
lr_entity_bp TYPE REF TO if_bol_bo_property_access,
lv_fullname TYPE BU_DESCRIP,
lv_bp_id TYPE bu_partner.

lr_entity ?= me->typed_context->bpinfo->collection_wrapper->get_current( ).
ASSERT lr_entity IS NOT INITIAL.
lr_node = mv_popup->get_context_node( 'PARTNER' ).
CHECK lr_node IS BOUND.

lr_entity_bp = lr_node->collection_wrapper->get_current( ).
CHECK lr_entity IS BOUND AND lr_entity_bp IS BOUND.
lv_bp_id = lr_entity_bp->get_property_as_string( 'BP_NUMBER' ).
CHECK lv_bp_id IS NOT INITIAL.

lr_entity->set_property( iv_attr_name = 'BP_ID' iv_value = lv_bp_id ).
CALL FUNCTION 'CRM_BUPA_DESCRIPTION_READ'
EXPORTING
iv_partner = lv_bp_id
IMPORTING
ev_description_name = lv_fullname
EXCEPTIONS
no_partner_specified = 1
no_valid_record_found = 2
OTHERS = 3.
lr_entity->set_property( iv_attr_name = 'BP_NAME' iv_value = lv_fullname ).




Note: when you create the outbound plug OP_PARTNER_SEARCH in step2, the method is created with Protected by default. You should change the visibility manually to Public:



or else you will meet with CX_BSP_WD_INCORRECT_IMPLEMENT exception, since in the runtime the framework would expect to call it as public method as below:




5 Comments