Skip to Content

Step by step to create value help

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,

/wp-content/uploads/2014/02/clipboard1_387307.png

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:

/wp-content/uploads/2014/02/clipboard2_387398.png

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

/wp-content/uploads/2014/02/clipboard3_387399.png

Step1: Implement GET_P method for field “BusinessPartner ID”:

/wp-content/uploads/2014/02/clipboard4_387400.png

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 )

/wp-content/uploads/2014/02/clipboard6_387404.png

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:

/wp-content/uploads/2014/02/clipboard7_387405.png

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:

/wp-content/uploads/2014/02/clipboard9_387406.png

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:

/wp-content/uploads/2014/02/clipboard10_387407.png

5 Comments
You must be Logged on to comment or reply to a post.
  • Hi,

    Thanks for this tutorial.

    I have a little problem : the outbound plug is not called.

    The GET_V method is done but the OP is not called. I put a breakpoint in it, but it doesn’t stop there.

    Of course, the OP is public.

    Do you have a clue ?

    Thank you.

  • Hi,
    Thanks for the tutorial. Actually, I’m facing the same problem as David. Checking the GET_V execution in debug mode, I figured out the problem is caused in casting section between:

    data: value_help_via_valuetable type ref to if_bsp_wd_valuehelp_pldescr,
    value_help_via_valuetable ?= value_help.
    or

    data: value_help_via_f4 type ref to if_bsp_wd_valuehelp_f4descr,
    value_help_via_f4 ?= value_help.

    Any suggestion?

    Thanks your time in advance.